skrifa::color

Enum Brush

source
pub enum Brush<'a> {
    Solid {
        palette_index: u16,
        alpha: f32,
    },
    LinearGradient {
        p0: Point<f32>,
        p1: Point<f32>,
        color_stops: &'a [ColorStop],
        extend: Extend,
    },
    RadialGradient {
        c0: Point<f32>,
        r0: f32,
        c1: Point<f32>,
        r1: f32,
        color_stops: &'a [ColorStop],
        extend: Extend,
    },
    SweepGradient {
        c0: Point<f32>,
        start_angle: f32,
        end_angle: f32,
        color_stops: &'a [ColorStop],
        extend: Extend,
    },
}
Expand description

A fill type of a COLRv1 glyph (solid fill or various gradient types).

The client receives the information about the fill type in the [fill``](ColorPainter::fill) callback of the [ColorPainter`] trait.

Variants§

§

Solid

A solid fill with the color specified by palette_index. The respective color from the CPAL table then needs to be multiplied with alpha.

Fields

§palette_index: u16
§alpha: f32
§

LinearGradient

A linear gradient, normalized from the P0, P1 and P2 representation in the COLRv1 table to a linear gradient between two points p0 and p1. If there is only one color stop, the client should draw a solid fill with that color. The color_stops are normalized to the range from 0 to 1.

Fields

§color_stops: &'a [ColorStop]
§extend: Extend
§

RadialGradient

A radial gradient, with color stops normalized to the range of 0 to 1. Caution: This normalization can mean that negative radii occur. It is the client’s responsibility to truncate the color line at the 0 position, interpolating between r0 and r1 and compute an interpolated color at that position.

Fields

§r0: f32
§r1: f32
§color_stops: &'a [ColorStop]
§extend: Extend
§

SweepGradient

A sweep gradient, also called conical gradient. The color stops are normalized to the range from 0 to 1 and the returned angles are to be interpreted in clockwise direction (swapped from the meaning in the font file). The stop normalization may mean that the angles may be larger or smaller than the range of 0 to 360. Note that only the range from 0 to 360 degrees is to be drawn, see https://learn.microsoft.com/en-us/typography/opentype/spec/colr#sweep-gradients.

Fields

§start_angle: f32
§end_angle: f32
§color_stops: &'a [ColorStop]
§extend: Extend

Trait Implementations§

source§

impl<'a> Debug for Brush<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> PartialEq for Brush<'a>

source§

fn eq(&self, other: &Brush<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> StructuralPartialEq for Brush<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Brush<'a>

§

impl<'a> RefUnwindSafe for Brush<'a>

§

impl<'a> Send for Brush<'a>

§

impl<'a> Sync for Brush<'a>

§

impl<'a> Unpin for Brush<'a>

§

impl<'a> UnwindSafe for Brush<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.