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§
- Fixed
Linear Gradient - Specification of a linear gradient.
- Fixed
Radial Gradient - Specification of a radial gradient in image-space.
- Font
Family - A reference to a font family.
- Font
Weight - A font weight, represented as a value in the range 1..=1000.
- Gradient
Stop - Specification of a gradient stop.
- HitTest
Point - Result of hit testing a point in a
TextLayout
. - HitTest
Position - Result of hit testing a text position in a
TextLayout
. - Image
Buf - An in-memory pixel buffer.
- Line
Metric - Metadata about each line in a text layout.
- Linear
Gradient - A description of a linear gradient in the unit rect, which can be resolved to a fixed gradient.
- Radial
Gradient - A description of a radial gradient in the unit rect, which can be resolved to a fixed gradient.
- Stroke
Dash - A type that represents an alternating pattern of drawn and undrawn segments.
- Stroke
Style - Options for drawing stroked lines.
- Unit
Point - A representation of a point relative to a unit rectangle.
Enums§
- Color
- A datatype representing color.
- Color
Parse Error - Errors that can occur when parsing a hex color.
- Error
- An error that can occur while rendering 2D graphics.
- Fixed
Gradient - Any fixed gradient.
- Font
Style - A font style, which may be italic or regular.
- Image
Format - The pixel format for bitmap images.
- Interpolation
Mode - A requested interpolation mode for drawing images.
- LineCap
- Options for the cap of stroked lines.
- Line
Join - Options for angled joins in strokes.
- Paint
Brush - A color or a gradient.
- Scale
Mode - Mappings from the unit square into a non-square rectangle.
- Text
Alignment - The alignment of text in a
TextLayout
. - Text
Attribute - Attributes that can be applied to text.
Traits§
- Gradient
Stops - A flexible, ergonomic way to describe gradient stops.
- Image
- A trait for a backend’s bitmap image type.
- Into
Brush - A trait for various types that can be used as brushes.
- Render
Context - The main trait for rendering graphics.
- Round
From - A trait for types that can be converted with precision loss.
- Round
Into - The companion to
RoundFrom
. - Text
- The Piet text API.
- Text
Layout - A drawable text object.
- Text
Layout Builder - A trait for laying out text.
- Text
Storage - A type that stores text.