pub struct ColrPainter<'a> {
transforms: Vec<Affine>,
color_glyph: Box<ColorGlyph<'a>>,
context_color: AlphaColor<Srgb>,
painter: &'a mut dyn ColrRenderer,
layer_count: u32,
}
Expand description
An abstraction for painting COLR glyphs.
Fields§
§transforms: Vec<Affine>
§color_glyph: Box<ColorGlyph<'a>>
§context_color: AlphaColor<Srgb>
§painter: &'a mut dyn ColrRenderer
§layer_count: u32
Implementations§
Source§impl<'a> ColrPainter<'a>
impl<'a> ColrPainter<'a>
Sourcepub fn new(
color_glyph: Box<ColorGlyph<'a>>,
context_color: AlphaColor<Srgb>,
painter: &'a mut impl ColrRenderer,
) -> Self
pub fn new( color_glyph: Box<ColorGlyph<'a>>, context_color: AlphaColor<Srgb>, painter: &'a mut impl ColrRenderer, ) -> Self
Create a new COLR painter.
fn cur_transform(&self) -> Affine
fn palette_index_to_color( &self, palette_index: u16, alpha: f32, ) -> Option<AlphaColor<Srgb>>
fn convert_stops(&self, stops: &[ColorStop]) -> ColorStops
Trait Implementations§
Source§impl ColorPainter for ColrPainter<'_>
impl ColorPainter for ColrPainter<'_>
Source§fn push_transform(&mut self, t: Transform)
fn push_transform(&mut self, t: Transform)
Push the specified transform by concatenating it to the current
transformation matrix.
Source§fn pop_transform(&mut self)
fn pop_transform(&mut self)
Restore the transformation matrix to the state before the previous
push_transform
call.Source§fn push_clip_glyph(&mut self, glyph_id: GlyphId)
fn push_clip_glyph(&mut self, glyph_id: GlyphId)
Apply a clip path in the shape of glyph specified by
glyph_id
.Source§fn push_clip_box(&mut self, clip_box: BoundingBox<f32>)
fn push_clip_box(&mut self, clip_box: BoundingBox<f32>)
Apply a clip rectangle specified by
clip_rect
.Source§fn pop_clip(&mut self)
fn pop_clip(&mut self)
Restore the clip state to the state before a previous
push_clip_glyph
or
push_clip_box
call.Source§fn fill(&mut self, brush: Brush<'_>)
fn fill(&mut self, brush: Brush<'_>)
Fill the current clip area with the specified gradient fill.
Source§fn push_layer(&mut self, composite_mode: CompositeMode)
fn push_layer(&mut self, composite_mode: CompositeMode)
Open a new layer, and merge the layer down using
composite_mode
when
pop_layer
is called, signalling that this layer is done drawing.Source§fn pop_layer(&mut self)
fn pop_layer(&mut self)
Merge the pushed layer down using
composite_mode
passed to the matching
push_layer
.Source§fn fill_glyph(
&mut self,
glyph_id: GlyphId,
brush_transform: Option<Transform>,
brush: Brush<'_>,
)
fn fill_glyph( &mut self, glyph_id: GlyphId, brush_transform: Option<Transform>, brush: Brush<'_>, )
Combined clip and fill operation. Read more
Source§fn paint_cached_color_glyph(
&mut self,
_glyph: GlyphId,
) -> Result<PaintCachedColorGlyph, PaintError>
fn paint_cached_color_glyph( &mut self, _glyph: GlyphId, ) -> Result<PaintCachedColorGlyph, PaintError>
Optionally implement this method: Draw an unscaled COLRv1 glyph given
the current transformation matrix (as accumulated by
push_transform
calls).Source§fn pop_layer_with_mode(&mut self, _composite_mode: CompositeMode)
fn pop_layer_with_mode(&mut self, _composite_mode: CompositeMode)
Alternative version of
push_layer
where the
composite_mode
is also passed to the method. This is useful for
graphics libraries that need the compositing mode at layer pop time
and do not want to manually track the mode. Read moreAuto Trait Implementations§
impl<'a> Freeze for ColrPainter<'a>
impl<'a> !RefUnwindSafe for ColrPainter<'a>
impl<'a> !Send for ColrPainter<'a>
impl<'a> !Sync for ColrPainter<'a>
impl<'a> Unpin for ColrPainter<'a>
impl<'a> !UnwindSafe for ColrPainter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more