[−][src]Module piet::gradient
Gradient specifications.
We provide both linear and radial gradients; and for each flavor we provide two representations, a 'generic' representation that uses points in the unit square, and a 'fixed' representation that uses image-space coordinates.
The generic representations (LinearGradient
and RadialGradient
)
are useful for cases such as UI, when the same gradient may be reused
with different shapes. The fixed representations
(FixedLinearGradient
and FixedRadialGradient
) may be better suited
to working with content in existing formats such as SVG. A fixed gradient
can be generated from a generic gradient by mapping points from the unit
square onto any arbitrary rectangle.
The fixed variants are provided because they more closely match the types used by many 2d graphics APIs; but you can use the generic representations anywhere you can use the fixed ones, and they will be automatically resolved appropriately.
Structs
FixedLinearGradient | Specification of a linear gradient. |
FixedRadialGradient | Specification of a radial gradient in image-space. |
GradientStop | Specification of a gradient stop. |
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. |
UnitPoint | A representation of a point relative to a unit rectangle. |
Enums
FixedGradient | Any fixed gradient. |
ScaleMode | Mappings from the unit square into a non-square rectangle. |
Constants
MAX_GRADIENT_STOPS |
Traits
GradientStops | A flexible, ergonomic way to describe gradient stops. |
Functions
equalize_sides_preserving_center |
Type Definitions
GradientStopArray |