This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 // self-compiling code | |
gcc -std=c99 -Wall -Wextra -pedantic -Werror -g -O4 -march=native $0 -lm || exit 1 | |
exec time ./a.out | |
#endif | |
// Blue Noise texture generation using the void-and-cluster algorithm | |
// implemented by Martin Fiedler <keyj@emphy.de> | |
// using an algorithm description written by Alan Wolfe: | |
// https://blog.demofox.org/2019/06/25/generating-blue-noise-textures-with-void-and-cluster/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rand; | |
extern crate amethyst; | |
use amethyst::{Application, Event, State, Trans, VirtualKeyCode, WindowEvent}; | |
use amethyst::asset_manager::AssetManager; | |
use amethyst::config::Element; | |
use amethyst::ecs::{World, Join, VecStorage, Component, RunArg, System, Entity}; | |
use amethyst::ecs::components::{Mesh, LocalTransform, Texture, Transform, Renderable}; | |
use amethyst::gfx_device::DisplayConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select(left, right): | |
"""Choose the minimum front from left and right, but handle empty lists.""" | |
return left.pop(0) if (len(left) > 0 and len(right) is 0) or (len(left) > 0 and left[0] < right[0]) else right.pop(0) | |
def merge(left, right): | |
"""Conquer: Merge together the selected (min) front of left and right.""" | |
return [select(left,right) for i in range((len(left) + len(right)))] | |
def sort(l): | |
"""Divide: Recursive call to split input list into managable sublists.""" |