[][src]Crate piet_common

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.

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

A garden of data structures for manipulating 2D shapes and curves.

Structs

BitmapTarget

A struct provides a RenderContext and then can have its bitmap extracted.

Device

A struct that can be used to create bitmap render contexts.

Error

An error that can occur while rendering 2D graphics.

FixedLinearGradient

Specification of a linear gradient.

FixedRadialGradient

Specification of a radial gradient in image-space.

GradientStop

Specification of a gradient stop.

HitTestMetrics

Hit test metrics, returned as part of hit_test_text_position and hit_test_point.

HitTestPoint

return values for hit_test_point.

HitTestTextPosition

return values for hit_test_text_position.

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.

StrokeStyle

Options for drawing stroked lines. Most of these are self explanatory, but some aren't.

UnitPoint

A representation of a point relative to a unit rectangle.

Enums

Color

A datatype representing color.

ErrorKind
FixedGradient

Any fixed gradient.

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.

Traits

Font
FontBuilder
GradientStops

A flexible, ergonomic way to describe gradient stops.

IntoBrush

A trait for various types that can be used as brushes. These include backend-independent types such Color and LinearGradient, as well as the types used to represent these on a specific backend.

RenderContext

The main trait for rendering graphics.

RoundFrom

This is our own implementation of a "lossy From" trait, representing a conversion that can have precision loss. It is essentially adapted from https://github.com/rust-lang/rfcs/pull/2484.

RoundInto

The companion to RoundFrom. As with From and Into, a blanket implementation is provided; for the most part, implement RoundFrom.

Text
TextLayout

Text Layout

TextLayoutBuilder

Functions

new_error

Create a new error of the given kind.

Type Definitions

Brush

The associated brush type for this backend.

Image

The associated image type for this backend.

Piet

The RenderContext for the Cairo backend, which is selected.

PietFont

The associated font type for this backend.

PietFontBuilder

The associated font builder for this backend.

PietText

The associated text factory for this backend.

PietTextLayout

The associated text layout type for this backend.

PietTextLayoutBuilder

The associated text layout builder for this backend.