rasterize/
lib.rs

1//! Simple 2D library that support SVG path parsing/generation/manipulation and rasterization.
2//!
3//! ## Main features:
4//!  - SVG path parsing and generation
5//!  - Anti-aliased rendering
6//!  - Path offsetting [`Path::stroke`]
7//!  - Linear and Radial gradients with [`GradLinear`] and [`GradRadial`]
8//!  - Serde integration if `serde` feature is set (enabled by default)
9//!
10//! ## Overview
11//! **Main types are:**
12//! - [`Path`] - Represents the same concept as an [SVG path](https://www.w3.org/TR/SVG11/paths.html),
13//!   the easiest way to construct it is with [`Path::builder`] or it can be parsed from SVG path with [`str::parse`].
14//!   Path can be stroked with [`Path::stroke`] to generated new path that represents an outline.
15//! - [`Scene`] - Represents an image that has not been rendered yet, multiple scenes
16//!   can be composed to construct more complex scene. This is probably the simplest
17//!   way to render something useful. See `examples/simple.rs` for a simple example.
18//!   It can also be (de)serialized see `data/firefox.scene` for an example.
19//! - [`Paint`] - Color/Gradient that can be used to fill a path.
20//! - [`Image`] - 2D matrix that can hold and image and used as a target for rendering.
21//!   Image can also be written into a file with [`Image::write_bmp`] or to PNG with
22//!   `Image::write_png` if `png` feature is enabled.
23#![deny(warnings)]
24#![allow(clippy::excessive_precision)]
25
26mod color;
27mod curve;
28mod ellipse;
29mod geometry;
30mod grad;
31mod image;
32mod path;
33mod rasterize;
34mod scene;
35pub mod simd;
36mod svg;
37pub mod utils;
38
39pub use crate::rasterize::{
40    ActiveEdgeIter, ActiveEdgeRasterizer, ArcPaint, Paint, Pixel, Rasterizer,
41    SignedDifferenceRasterizer, Size, Units,
42};
43#[cfg(feature = "serde")]
44pub use color::RGBADeserializer;
45pub use color::{Color, ColorError, LinColor, RGBA, SVG_COLORS, linear_to_srgb, srgb_to_linear};
46pub use curve::{
47    Cubic, Curve, CurveExtremities, CurveFlattenIter, CurveRoots, Line, Quad, Segment,
48};
49pub use ellipse::EllipArc;
50pub use geometry::{
51    Align, BBox, EPSILON, EPSILON_SQRT, PI, Point, Scalar, ScalarFormat, ScalarFormatter, Transform,
52};
53pub use grad::{GradLinear, GradRadial, GradSpread, GradStop, GradStops};
54pub use image::{
55    Image, ImageIter, ImageMut, ImageMutIter, ImageMutRef, ImageOwned, ImageRef, ImageWriteFormat,
56    Shape,
57};
58pub use path::{
59    DEFAULT_FLATNESS, FillRule, LineCap, LineJoin, Path, PathBuilder, StrokeStyle, SubPath,
60};
61pub use scene::{Layer, Scene};
62pub use svg::{SvgParserError, SvgPathCmd, SvgPathParser};