Expand description
A piet backend appropriate for the current platform.
This crate reexports the piet crate, alongside an appropriate backend for the given platform. It also exposes kurbo, which defines shape and curve types useful in drawing, and image for image manipulation.
The intention of this crate is to provide a single dependency that handles the common piet use-case. If you have more complicated needs (such as supporting multiple backends simultaneously) you should use crates such as piet and piet-cairo directly.
The associated types for brushes, text, and images are exported as type definitions (resolving to concrete types within the backend), so they can be used directly. The text-related types are prefixed with “Piet” to avoid conflict with the text traits that would otherwise have the same name.
Also note that all public types for the specific backend are re-exported, but have their docs hidden here. These types can be useful for platform integration, and also potentially to access extensions specific to the backend. The types documented below can be used portable across all backends.
Modules§
- kurbo
- 2D geometry, with a focus on curves.
- util
- utilities shared by various backends Code useful for multiple backends
Structs§
- Bitmap
Target - A struct provides a
RenderContext
and then can have its bitmap extracted. - Device
- A struct that can be used to create bitmap render contexts.
- 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.
Type Aliases§
- Brush
- The associated brush type for this backend.
- Piet
- The
RenderContext
for the Cairo backend, which is selected. - Piet
Image - The associated image type for this backend.
- Piet
Text - The associated text factory for this backend.
- Piet
Text Layout - The associated text layout type for this backend.
- Piet
Text Layout Builder - The associated text layout builder for this backend.