Crate starry_mosaic

Crate starry_mosaic 

Source
Expand description

A library for generating colorful mosaic images with various geometrical patterns.

§How to create mosaic image

To create mosaic simply:

  • set size of resulting image;
  • choose shape which mosaic is based on,
  • set its position, rotation and scale
  • and finally select type of mosaic.

Then this mosaic can be painted with any color or gradient.

In code whole process looks like this:

use palette::LinSrgb;
use starry_mosaic::{Mosaic, MosaicBuilder, Vector};

let starry_mosaic = MosaicBuilder::default()
    .set_image_size(1920, 1080)
    .set_regular_polygon_shape(12)
    .set_center(Vector::new(1280.0, 540.0))
    .set_uniform_scale(0.6)
    .build_star()
    .unwrap();

let starry_mosaic_image = starry_mosaic.draw(LinSrgb::new(0.0f64, 0.25, 1.0));

let save_result = starry_mosaic_image.save("target/starry_mosaic_image.png");
assert!(save_result.is_ok());

let polygonal_mosaic = MosaicBuilder::from(&starry_mosaic)
    .build_polygon()
    .unwrap();

let polygonal_mosaic_image = polygonal_mosaic.draw(LinSrgb::new(0.0f64, 0.25, 1.0));

let save_result = polygonal_mosaic_image.save("target/polygonal_mosaic_image.png");
assert!(save_result.is_ok());

Modules§

coloring_method
This module provides various coloring methods to paint mosaic and so create painted mosaic images.
mosaic_shape
This module provides types to create various shapes of mosaic.
transform

Structs§

MosaicBuilder
Builds different mosaics from set of its properties.
PolygonalMosaic
Represents polygonal mosaic and creates mosaic images painted with with different methods.
Segment
Represents 2D line segment.
StarryMosaic
Represents starry mosaic and creates mosaic images painted with with different methods.
Vector
Represents 2D vector.

Traits§

Mosaic
Represents mosaic and allows to create mosaic images painted with different methods.