voxgen/
lib.rs

1#![doc = include_str!("../README.md")]
2
3/// A voxel grid data structure.
4///
5/// Implemented based on the [image](https://crates.io/crates/image) crate.
6pub mod voxel_buffer;
7
8/// Draw on voxel buffers using turtle graphics.
9///
10/// Use basic turtle graphics commands and save outputs as magicavoxel .vox
11/// files.  Implemented based on the descriptions in [The Algorithmic Beauty of
12/// Plants](http://algorithmicbotany.org/papers/abop/abop-ch1.pdf).
13pub mod turtle_graphics;
14
15/// Inteprets L System strings and draws them using turtle graphics.
16///
17/// Implemented based on the descriptions in [The Algorithmic Beauty of
18/// Plants](http://algorithmicbotany.org/papers/abop/abop-ch1.pdf).
19///
20/// # Examples
21///
22/// Render a Sierpinski gasket.
23/// ```
24/// # use voxgen::l_system::{LSystem, RenderOptions};
25/// let l_system = LSystem::new(
26///     "sierpinski-gasket",
27///     "R",
28///     vec![
29///         "L→R+L+R",
30///         "R→L-R-L",
31///     ]
32/// );
33/// RenderOptions::new()
34///     .derivation_length(3)
35///     .step_size(4.0)
36///     .angle_increment(std::f32::consts::FRAC_PI_3)
37///     .offset_y(-20.0)
38///     .render(l_system);
39/// ```
40///
41/// Render a Hilbert curve.
42/// ```
43/// # use voxgen::l_system::{LSystem, RenderOptions};
44/// let l_system = LSystem::new(
45///     "hilbert",
46///     "A",
47///     vec![
48///         "A→+BF-AFA-FB+",
49///         "B→-AF+BFB+FA-",
50///     ],
51/// );
52/// RenderOptions::new()
53///     .size_x(127)
54///     .size_y(127)
55///     .offset_x(63.0)
56///     .offset_y(-63.0)
57///     .derivation_length(6)
58///     .render(l_system);
59/// ```
60pub mod l_system;