Skip to main content

Painter

Trait Painter 

Source
pub trait Painter {
    // Required method
    fn paint_content(
        &self,
        canvas: &Canvas,
        layout: &BoxLayout,
        props: &AnimatedProperties,
        ctx: &PaintCtx,
    );

    // Provided method
    fn intrinsic_size(
        &self,
        _available: AvailableSize,
        _ctx: &MeasureCtx,
    ) -> Option<(f32, f32)> { ... }
}
Expand description

Component paint contract.

Required Methods§

Source

fn paint_content( &self, canvas: &Canvas, layout: &BoxLayout, props: &AnimatedProperties, ctx: &PaintCtx, )

Paint the component’s content into the canvas. The canvas is already translated to the content-box origin and clipped if overflow: hidden was set. Generic decorations (bg, border, shadow) are already painted by the engine.

props carries the per-component animation state at the current frame. Outer paint properties (transform / opacity / filter) have already been applied to the canvas by the engine via CSS overrides; props exposes the internal-only fields (draw_progress, stroke_width, char_animation, visible_chars*, font_size, color, border_radius, etc.) that components use to drive their own painting.

Provided Methods§

Source

fn intrinsic_size( &self, _available: AvailableSize, _ctx: &MeasureCtx, ) -> Option<(f32, f32)>

Optional intrinsic measurement for leaves like text, image, codeblock. Return None to let taffy compute the size from the CSS style alone. available mirrors taffy’s AvailableSpace.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§