Crate piet[][src]

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.


pub use kurbo;


utilities shared by various backends Code useful for multiple backends


Specification of a linear gradient.

Specification of a radial gradient in image-space.

A reference to a font family.

A font weight, represented as a value in the range 1..=1000.

Specification of a gradient stop.

Result of hit testing a point in a TextLayout.

Result of hit testing a text position in a TextLayout.

An in-memory pixel buffer.

Metadata about each line in a text layout.

A description of a linear gradient in the unit rect, which can be resolved to a fixed gradient.

A description of a radial gradient in the unit rect, which can be resolved to a fixed gradient.

A type that represents an alternating pattern of drawn and undrawn segments.

Options for drawing stroked lines.

A representation of a point relative to a unit rectangle.


A datatype representing color.

Errors that can occur when parsing a hex color.

An error that can occur while rendering 2D graphics.

Any fixed gradient.

A font style, which may be italic or regular.

The pixel format for bitmap images.

A requested interpolation mode for drawing images.

Options for the cap of stroked lines.

Options for angled joins in strokes.

A color or a gradient.

Mappings from the unit square into a non-square rectangle.

The alignment of text in a TextLayout.

Attributes that can be applied to text.


A flexible, ergonomic way to describe gradient stops.

A trait for a backend’s bitmap image type.

A trait for various types that can be used as brushes.

The main trait for rendering graphics.

A trait for types that can be converted with precision loss.

The companion to RoundFrom.

The Piet text API.

A drawable text object.

A trait for laying out text.

A type that stores text.