Struct Fractal

Source
pub struct Fractal {
    pub image: Img,
}
Expand description

The structure of the Fractal.

Fields§

§image: Img

The fractal’s image data.

Implementations§

Source§

impl Fractal

Source

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);
Source

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");
Source

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.

Source

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));
Source

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));
Source

pub fn triangle(&mut self, x: u32, y: u32, h: u32, color: Pixel)

Generate a triange by giving its coordinates, height and color.

Source

pub fn trianglev2(&mut self, x: u32, y: u32, h: u32, color: Pixel)

Generate a triange by giving its coordinates, height and color.

Source

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.

Source

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));
Source

pub fn mandelbrot(&mut self, color: Pixel)

Generate a Mandelbrot Set with the given color.

§Example
image.mandelbrot(Pixel::new(250, 0, 0));
Source

pub fn rotate(&mut self)

Rotate the fractal by 90 degrees.

Source

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));
Source

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));
Source

pub fn julia(&mut self)

Generate a Julia Set.

§Example
image.julia();
Source

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));

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.