pub struct Fractal {
pub image: Img,
}Expand description
The structure of the Fractal.
Fields§
§image: ImgThe fractal’s image data.
Implementations§
Source§impl Fractal
impl Fractal
Sourcepub fn new(pixels: Vec<Vec<Pixel>>) -> Fractal
pub fn new(pixels: Vec<Vec<Pixel>>) -> Fractal
Create a Fractal by giving the pixels as a 2D Vector.
§Example
let mut image = Fractal::new(pixels);Sourcepub fn write_image(&self, path: &str)
pub fn write_image(&self, path: &str)
Write the image as a bmp file in the given path.
§Example
let image = image::Img::new(pixels);
image.write_image("./myimage.bmp");Sourcepub fn circle(&mut self, xc: usize, yc: usize, radius: u32, color: Pixel)
pub fn circle(&mut self, xc: usize, yc: usize, radius: u32, color: Pixel)
Generate a circle by giving the center coordinates, the radius, and the color.
Sourcepub fn multiple_circles(
&mut self,
xc: usize,
yc: usize,
radius: u32,
number: u32,
color: Pixel,
)
pub fn multiple_circles( &mut self, xc: usize, yc: usize, radius: u32, number: u32, color: Pixel, )
Generate repeating circle patterns where each circle’s radius is decremented by number.
§Example
image.multiple_circles(825, 825, 125, 6, Pixel::new(0, 150, 150));Sourcepub fn koch_curve(
&mut self,
p1x: i32,
p1y: i32,
p2x: i32,
p2y: i32,
amount: u32,
color: Pixel,
)
pub fn koch_curve( &mut self, p1x: i32, p1y: i32, p2x: i32, p2y: i32, amount: u32, color: Pixel, )
Generate a Koch Curve by giving the start and end coordinates, the color, and the amount of recursion. Keep in mind that the time to run increases significantly as amount increases.
§Example
image.koch_curve(675, 75, 925, 325, 5, Pixel::new(0, 250, 0));Sourcepub fn triangle(&mut self, x: u32, y: u32, h: u32, color: Pixel)
pub fn triangle(&mut self, x: u32, y: u32, h: u32, color: Pixel)
Generate a triange by giving its coordinates, height and color.
Sourcepub fn trianglev2(&mut self, x: u32, y: u32, h: u32, color: Pixel)
pub fn trianglev2(&mut self, x: u32, y: u32, h: u32, color: Pixel)
Generate a triange by giving its coordinates, height and color.
Sourcepub fn sierpinski_triangle(&mut self, x: u32, y: u32, h: u32, color: Pixel)
pub fn sierpinski_triangle(&mut self, x: u32, y: u32, h: u32, color: Pixel)
Generate a Sierpinksi Triange by giving its coordinates, height, and color.
Sourcepub fn multiple_triangles(
&mut self,
x: u32,
y: u32,
h: u32,
number: u32,
color: Pixel,
)
pub fn multiple_triangles( &mut self, x: u32, y: u32, h: u32, number: u32, color: Pixel, )
Generate repeating triangles where each triangles height is decremented by number.
§Example
image.multiple_triangles(175, 800, 220, 6, Pixel::new(250, 0, 250));Sourcepub fn mandelbrot(&mut self, color: Pixel)
pub fn mandelbrot(&mut self, color: Pixel)
Sourcepub fn tree(
&mut self,
x: u32,
y: u32,
h: u32,
angle: f64,
growth: u32,
color: Pixel,
)
pub fn tree( &mut self, x: u32, y: u32, h: u32, angle: f64, growth: u32, color: Pixel, )
Generate a tree by giving its coordinates, height, angle, growth, and color.
§Example
image.tree(100, 800, 100, PI / 4.0, 2, Pixel::new(0, 0, 255));Sourcepub fn barnsley_fern(&mut self, x: i32, y: u32, iterations: u32, color: Pixel)
pub fn barnsley_fern(&mut self, x: i32, y: u32, iterations: u32, color: Pixel)
Generate a fern by selecting its coordinates, number of iterations, and color. The more iterations, the better the shape becomes a fern. A good value is about 5000000.
§Example
image.barnsley_fern(500, 100, 5000000, Pixel::new(255, 0, 0));Sourcepub fn julia_colored(&mut self, color: Pixel)
pub fn julia_colored(&mut self, color: Pixel)
Generate a Julia Set with a mixture of colors given in the pixel parameter.
§Example
image.julia_colored(Pixel::new(250, 150, 100));