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)

§Overview

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/simple.rs 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.

Modules§

simd
utils
Utility functions and types used across the library

Structs§

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

Enums§

Align
Alignment options
ColorError
FillRule
The algorithm to use to determine the inside part of a shape, when filling it.
GradSpread
Gradient spread logic for the parameter smaller than 0 and greater than 1
ImageWriteFormat
LineCap
LineCap specifies the shape to be used at the end of open sub-paths when they are stroked. See SVG specification for more details.
LineJoin
LineJoin defines the shape to be used at the corners of paths when they are stroked. See SVG specification for more details.
Segment
Segment is an enum of either Line, Quad or Cubic
SvgParserError
Error while parsing path in the SVG format
SvgPathCmd
Possible SVG path commands
Units

Constants§

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

Statics§

SVG_COLORS

Traits§

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

Functions§

linear_to_srgb
Convert Linear RGB color component into a SRGB color component.
srgb_to_linear

Type Aliases§

ArcPaint
CurveExtremities
Iterator containing curve extremities
CurveRoots
Iterator containing curve roots
Scalar
Scalar type