Add missing documentation
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
//! # Chaos Game
|
||||
//!
|
||||
//! Fractal flames are a class of
|
||||
//! [iterated function systems](https://en.wikipedia.org/wiki/Iterated_function_system)
|
||||
//! that generate images following a simple algorithm:
|
||||
//!
|
||||
//! - Pick a starting point `(x, y)`
|
||||
//! - Iterate:
|
||||
//! - Pick a [`Transform`] from the set of available transforms
|
||||
//! - Apply the current point to the chosen transform, generating a new point `(x, y)`
|
||||
//! - Plot the new point `(x, y)`
|
||||
//!
|
||||
//! This algorithm is also known as the ["chaos game"](https://en.wikipedia.org/wiki/Chaos_game),
|
||||
//! and it forms the basic system for producing images.
|
||||
use crate::transform::Transform;
|
||||
use glam::{Vec2, vec2};
|
||||
use rand::distr::{Distribution, StandardUniform};
|
||||
@@ -42,6 +56,10 @@ pub fn step_chaos_game<R: Rng>(
|
||||
)
|
||||
}
|
||||
|
||||
/// Iterator for chaos game state. Holds the current point and references to all other data
|
||||
/// necessary to generate fractal flame images.
|
||||
///
|
||||
/// New points in the chaos game are produced by iterating on the chaos game.
|
||||
pub struct ChaosGame<'a, R: Rng> {
|
||||
current_point: Vec2,
|
||||
rng: &'a mut R,
|
||||
@@ -50,6 +68,7 @@ pub struct ChaosGame<'a, R: Rng> {
|
||||
}
|
||||
|
||||
impl<'a, R: Rng> ChaosGame<'a, R> {
|
||||
/// Create a new chaos game iterator
|
||||
pub fn new(rng: &'a mut R, transforms: &'a [Transform], weights: &'a [f32]) -> Self {
|
||||
let current_point = vec2(rng.sample(BiUnit), rng.sample(BiUnit));
|
||||
ChaosGame {
|
||||
|
||||
Reference in New Issue
Block a user