Skip to main content

Crate geometrize

Crate geometrize 

Source
Expand description

§Geometrize

Transform images into geometric art.

This crate provides two rendering styles:

  • Low-poly: Decomposes an image into colored triangles via Delaunay triangulation.
  • Pointillist: Renders the same triangulation as overlapping circles.

§Quick Start

Images are transformed using the geometrize function.

use geometrize::{geometrize, Style, SamplingParams};
use image::{open, RgbaImage};

let image = open("launch.jpg").unwrap();
 
let lowpoly: RgbaImage = geometrize(
    &image,
    Style::Lowpoly,
    70_000,
    SamplingParams::default()
).unwrap();
lowpoly.save("lowpoly_70k.png").unwrap();

let pointillist: RgbaImage = geometrize(
    &image,
    Style::Pointillist {noise: 0.0},
    20_000,
    SamplingParams::default()
).unwrap();
pointillist.save("pointillist_20k.png").unwrap();
launch.jpg
lowpoly_70k.png
pointillist_20k.png

§Transparent images

This also works with transparent images.


let image = open("dice.png").unwrap();
 
let lowpoly: RgbaImage = geometrize(
    &image,
    Style::Lowpoly,
    50_000,
    SamplingParams::default()
).unwrap();
lowpoly.save("lowpoly_50k_dice.png").unwrap();

let pointillist: RgbaImage = geometrize(
    &image,
    Style::Pointillist {noise: 0.0},
    10_000,
    SamplingParams::default()
).unwrap();
pointillist.save("pointillist_10k_dice.png").unwrap();
dice.png
lowpoly_50k_dice.png
pointillist_10k_dice.png

Structs§

SamplingParams
Parameters controlling how sample points are chosen from the image.

Enums§

EdgePoints
Controls how many sample points are placed along the image border.
GeometrizeError
Error type for geometrize.
SampleSeed
Source of randomness for point sampling.
Style
The visual style used to render the output image.

Functions§

geometrize
Convert an image into geometric art.
seed_from_image
Derive a seed from the content of an image.