Crate rasterize

source ·
Expand description

Simple 2D library that support SVG path parsing/generation/manipulation and rasterization.

§Main features:

  • SVG path parsing and generation
  • Anti-aliased rendering
  • Path offsetting Path::stroke
  • Linear and Radial gradients with GradLinear and GradRadial
  • Serde integration if serde feature is set (enabled by default)


Main types are:

  • Path - Represents the same concept as an SVG path, the easiest way to construct it is with Path::builder or it can be parsed from SVG path with str::parse. Path can be stroked with Path::stroke to generated new path that represents an outline.
  • Scene - Represents an image that has not been rendered yet, multiple scenes can be composed to construct more complex scene. This is probably the simplest way to render something useful. See examples/ for a simple example. It can also be (de)serialized see data/firefox.scene for an example.
  • Paint - Color/Gradient that can be used to fill a path.
  • Image - 2D matrix that can hold and image and used as a target for rendering. Image can also be written into a file with Image::write_bmp or to PNG with Image::write_png if png feature is enabled.


  • pub use color::SVG_COLORS;
  • pub use color::SVG_COLORS;


  • Utility functions and types used across the library


  • Iterator over rasterized pixels, by active-edge rasterizer
  • Active-Edge rasterizer
  • Bounding box with sides directed along the axes
  • Cubic bezier curve
  • Iterator over line segments approximating curve segment
  • Elliptical Arc
  • Linear Gradient
  • Radial Gradient
  • Specifies color at a particular parameter offset of the gradient
  • List of all GradStop in the gradient
  • Immutable iterator over pixels
  • Iterator over mutable references to all the pixels of the image
  • Mutable reference to an image or another mutable reference
  • Create an image that owns the data
  • Reference to an image or another reference
  • Image with top left corner at (x, y) coordinates
  • Alpha premultiplied RGBA color in the linear color space (no gamma correction)
  • Line segment curve
  • Collection of the SubPath treated as a single unit. Represents the same concept as an SVG path
  • Path builder similar to Canvas/Cairo interface.
  • Rasterized pixel
  • Value representing a 2D point or vector.
  • Quadratic bezier curve
  • sRGBA color packed as [u8; 4]
  • Represents an image that has not been rendered yet, multiple scenes can be composed to construct more complex scene.
  • Shape defines size and layout of the data inside an image
  • Signed difference based rasterizer
  • Size of the rectangular area with integer width and height
  • Style used to generate stroke
  • Non-empty collections of segments where end of each segments coincides with the start of the next one.
  • Path parser for SVG encoded path
  • 2D affine transformation



  • Default flatness used during rasterization. Value of 0.05px gives good accuracy tradeoff.
  • Epsilon value
  • Square root of the epsilon value
  • Mathematical pi constant


  • Common interface to all color representations
  • Set of operations common to all bezier curves.
  • Trait common to all image types
  • Mutable image interface
  • Common interface for anything that can be used to fill an area
  • Basic rasterizer interface


Type Aliases§