Crate piet

Source
Expand description

A 2D graphics abstraction.

This crate contains types and interfaces that represent a traditional 2D graphics API, in the tradition of PostScript. It is built on top of kurbo, a 2D geometry library.

The main interface is the RenderContext trait.

This API can be implemented on various platforms, allowing drawing code to be reused in an approximately consistent way. Various such implementations exist, such as piet-cairo, piet-coregraphics, and piet-direct2d.

If you are interested in using piet to target multiple platforms, piet-common is a utility crate that re-exports an appropriate backend based on the compile target, and provides convenience types and methods for setting up a RenderContext.

Re-exports§

pub use kurbo;

Modules§

util
utilities shared by various backends Code useful for multiple backends

Structs§

FixedLinearGradient
Specification of a linear gradient.
FixedRadialGradient
Specification of a radial gradient in image-space.
FontFamily
A reference to a font family.
FontWeight
A font weight, represented as a value in the range 1..=1000.
GradientStop
Specification of a gradient stop.
HitTestPoint
Result of hit testing a point in a TextLayout.
HitTestPosition
Result of hit testing a text position in a TextLayout.
ImageBuf
An in-memory pixel buffer.
LineMetric
Metadata about each line in a text layout.
LinearGradient
A description of a linear gradient in the unit rect, which can be resolved to a fixed gradient.
RadialGradient
A description of a radial gradient in the unit rect, which can be resolved to a fixed gradient.
StrokeDash
A type that represents an alternating pattern of drawn and undrawn segments.
StrokeStyle
Options for drawing stroked lines.
UnitPoint
A representation of a point relative to a unit rectangle.

Enums§

Color
A datatype representing color.
ColorParseError
Errors that can occur when parsing a hex color.
Error
An error that can occur while rendering 2D graphics.
FixedGradient
Any fixed gradient.
FontStyle
A font style, which may be italic or regular.
ImageFormat
The pixel format for bitmap images.
InterpolationMode
A requested interpolation mode for drawing images.
LineCap
Options for the cap of stroked lines.
LineJoin
Options for angled joins in strokes.
PaintBrush
A color or a gradient.
ScaleMode
Mappings from the unit square into a non-square rectangle.
TextAlignment
The alignment of text in a TextLayout.
TextAttribute
Attributes that can be applied to text.

Traits§

GradientStops
A flexible, ergonomic way to describe gradient stops.
Image
A trait for a backend’s bitmap image type.
IntoBrush
A trait for various types that can be used as brushes.
RenderContext
The main trait for rendering graphics.
RoundFrom
A trait for types that can be converted with precision loss.
RoundInto
The companion to RoundFrom.
Text
The Piet text API.
TextLayout
A drawable text object.
TextLayoutBuilder
A trait for laying out text.
TextStorage
A type that stores text.