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
.
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.
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.
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.