Trait skrifa::color::ColorPainter

source ·
pub trait ColorPainter {
    // Required methods
    fn push_transform(&mut self, transform: Transform);
    fn pop_transform(&mut self);
    fn push_clip_glyph(&mut self, glyph_id: GlyphId);
    fn push_clip_box(&mut self, clip_box: BoundingBox<f32>);
    fn pop_clip(&mut self);
    fn fill(&mut self, brush: Brush<'_>);
    fn push_layer(&mut self, composite_mode: CompositeMode);
    fn pop_layer(&mut self);

    // Provided methods
    fn fill_glyph(
        &mut self,
        glyph_id: GlyphId,
        brush_transform: Option<Transform>,
        brush: Brush<'_>,
    ) { ... }
    fn paint_cached_color_glyph(
        &mut self,
        _glyph: GlyphId,
    ) -> Result<PaintCachedColorGlyph, PaintError> { ... }
}
Expand description

A group of required painting callbacks to be provided by the client.

Each callback is executing a particular drawing or canvas transformation operation. The trait’s callback functions are invoked when paint is called with a ColorPainter trait object. The documentation for each function describes what actions are to be executed using the client side 2D graphics API, usually by performing some kind of canvas operation.

Required Methods§

source

fn push_transform(&mut self, transform: Transform)

Push the specified transform by concatenating it to the current transformation matrix.

source

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)

Apply a clip path in the shape of glyph specified by glyph_id.

source

fn push_clip_box(&mut self, clip_box: BoundingBox<f32>)

Apply a clip rectangle specified by clip_rect.

source

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<'_>)

Fill the current clip area with the specified gradient fill.

source

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)

Provided Methods§

source

fn fill_glyph( &mut self, glyph_id: GlyphId, brush_transform: Option<Transform>, brush: Brush<'_>, )

Combined clip and fill operation.

Apply the clip path determined by the specified glyph_id, then fill it with the specified brush, applying the _brush_transform transformation matrix to the brush. The default implementation works based on existing methods in this trait. It is recommended for clients to override the default implementaition with a custom combined clip and fill operation. In this way overriding likely results in performance gains depending on performance characteristics of the 2D graphics stack that these calls are mapped to.

source

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

Implementors§