pub enum Paint {
Solid(Color),
LinearGradient(LinearGradient),
RadialGradient(RadialGradient),
Blend(Vec<(Paint, f64)>),
MeshGradient(MeshGradient),
}Expand description
Describes how to fill vector geometry. Solid fills interpolate their RGBA channels. Other pairs crossfade sampled paints in premultiplied RGBA, preserving each gradient’s geometry and stops.
Variants§
Solid(Color)
A single solid color.
LinearGradient(LinearGradient)
A linear gradient.
RadialGradient(RadialGradient)
A radial gradient.
Blend(Vec<(Paint, f64)>)
A weighted paint mixture produced by interpolation. Weights are finite,
nonnegative, and sum to one. Use Paint::blend to normalize weights,
flatten nested mixtures, and combine repeated endpoints.
MeshGradient(MeshGradient)
A row-connected bicubic field with independently positioned colored anchors.
Implementations§
Source§impl Paint
impl Paint
Sourcepub fn blend(terms: Vec<(Paint, f64)>) -> Paint
pub fn blend(terms: Vec<(Paint, f64)>) -> Paint
Constructs a normalized mixture of paints. Nested mixtures are flattened and identical endpoints merged, so repeated interruptions between a fixed set of themes do not accumulate a history of blend nodes. Nonpositive or nonfinite weights are ignored; an empty mixture is transparent.
Sampling cost grows with the number of distinct endpoints still visible. A completed interpolation returns its destination paint directly.
Sourcepub fn representative_color(&self) -> Color
pub fn representative_color(&self) -> Color
Representative solid color for native text, which currently uses the first stop of a gradient. Mixtures crossfade those representative colors.
pub fn to_unit_point(_: (Size, Size), _: (f64, f64)) -> UnitPoint
pub fn to_piet_gradient_stops(stops: Vec<GradientStop>) -> Vec<GradientStop>
Sourcepub fn linearGradient(
start: (Size, Size),
end: (Size, Size),
stops: Vec<GradientStop>,
) -> Paint
pub fn linearGradient( start: (Size, Size), end: (Size, Size), stops: Vec<GradientStop>, ) -> Paint
Constructs a linear gradient paint.
Pax templates should normally use @gradient. When this helper is
needed explicitly, pass start and end as [x, y] lists.
Sourcepub fn with_alpha_factor(&self, factor: f64) -> Paint
pub fn with_alpha_factor(&self, factor: f64) -> Paint
Returns a copy of this paint with alpha multiplied by factor.
Sourcepub fn max_alpha_0_1(&self) -> f64
pub fn max_alpha_0_1(&self) -> f64
Returns a conservative upper bound for this paint’s alpha. For mixtures, endpoint maxima need not occur at the same point.
Sourcepub fn coverage_alpha_0_1(&self) -> f64
pub fn coverage_alpha_0_1(&self) -> f64
Estimates the alpha coverage contributed by this fill.
Trait Implementations§
Source§impl CoercionRules for Paint
impl CoercionRules for Paint
Source§fn try_coerce(pax_value: PaxValue) -> Result<Paint, String>
fn try_coerce(pax_value: PaxValue) -> Result<Paint, String>
value into Self.Source§fn allows_singleton_stack() -> bool
fn allows_singleton_stack() -> bool
Source§fn is_identity_roundtrip() -> bool
fn is_identity_roundtrip() -> bool
Self preserves the semantics of converting that clone
through ToPaxValue and back with try_coerce. Read moreSource§impl<'de> Deserialize<'de> for Paint
impl<'de> Deserialize<'de> for Paint
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Paint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Paint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl HelperFunctions for Paint
impl HelperFunctions for Paint
Source§fn register_all_functions()
fn register_all_functions()
Source§impl Interpolatable for Paint
impl Interpolatable for Paint
Source§impl Serialize for Paint
impl Serialize for Paint
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Paint
Source§impl ToPaxValue for Paint
impl ToPaxValue for Paint
Source§fn to_pax_value(self) -> PaxValue
fn to_pax_value(self) -> PaxValue
PaxValue.Source§fn nested_properties(&self) -> Vec<UntypedProperty>
fn nested_properties(&self) -> Vec<UntypedProperty>
Source§fn to_pax_value_in_graph(self) -> PaxValuewhere
Self: Sized,
fn to_pax_value_in_graph(self) -> PaxValuewhere
Self: Sized,
Self::to_pax_value reads published value snapshots.