A WebAssembly library written in Rust, which generates mazes, and also generates vertex buffers and indices to be used in a WebGL context to render out as basic maze.
To build the WebAssembly module, you need
Rust and
wasm-pack
.
Once you have those installed, to build the module, run
wasm-pack build
To build without the console_error_panic_hook
feature (adds better console
logging on panic, but increases build size quite a lot), remove the default
features,
wasm-pack build -- --no-default-features
To build with wee_alloc
feature (decreases build size a bit, but a bit slower
memory allocation),
wasm-pack build -- --features wee_alloc
You can also combine both the options as you like.
Once built, you'll be left with a WebAssembly module in ./pkg
. To include the
module in you npm or Yarn, add it to the dependencies
section as such:
{
"dependencies": {
"maze-generator-two": "portal:<path/to/pkg>"
}
}
An enum, representing the available maze algorithms to generate a maze.
Enum variant, which generates a maze using randomised depth-first search.
Enum variant, which generates a maze using randomised Kruskal's algorithm.
Class representing a rectangular maze with square cells, each cell having 4 neighbours.
SquareMaze.from_seed(width: usize, height: usize, algo: MazeAlgo, seed_p1: u32, seed_p2: u32) -> SquareMaze
Generates a new SquareMaze
of the given width, height, using the specified
maze generation algorithm, and with the provided seed (needs a 64-bit seed, so
we need to provide 2 32-bit ints).
Returns the width of a generated maze.
Returns the height of a generated maze.
Returns the provided seed_p1
of a maze during its generation.
Returns the provided seed_p2
of a maze during its generation.
Class which contains methods to get the required array buffers and element indices to render the maze in a WebGL context.
Generates the buffers for the given Square Maze and the given ratio of wall thickness to path thickness.
Return a pointer to the vertex array buffer and its size respectively.
Return a pointer to the element indices array buffer and its size respectively.