Skip to main content

PaintScene

Trait PaintScene 

Source
pub trait PaintScene: RenderContext {
    // Required methods
    fn reset(&mut self);
    fn push_layer(
        &mut self,
        blend: impl Into<BlendMode>,
        alpha: f32,
        transform: Affine,
        clip: &impl Shape,
        filter: Option<Arc<Filter>>,
        backdrop_filter: Option<Arc<Filter>>,
    );
    fn push_clip_layer(&mut self, transform: Affine, clip: &impl Shape);
    fn pop_layer(&mut self);
    fn stroke<'a>(
        &mut self,
        style: &Stroke,
        transform: Affine,
        brush: impl Into<PaintRef<'a>>,
        brush_transform: Option<Affine>,
        shape: &impl Shape,
    );
    fn fill<'a>(
        &mut self,
        style: Fill,
        transform: Affine,
        brush: impl Into<PaintRef<'a>>,
        brush_transform: Option<Affine>,
        shape: &impl Shape,
    );
    fn draw_glyphs<'a, 's: 'a>(
        &'s mut self,
        font: &'a FontData,
        font_size: f32,
        hint: bool,
        normalized_coords: &'a [NormalizedCoord],
        embolden: Vec2,
        style: impl Into<StyleRef<'a>>,
        brush: impl Into<PaintRef<'a>>,
        brush_alpha: f32,
        transform: Affine,
        glyph_transform: Option<Affine>,
        glyphs: impl Iterator<Item = Glyph> + Clone,
    );
    fn draw_box_shadow(
        &mut self,
        transform: Affine,
        rect: Rect,
        brush: Color,
        radius: f64,
        std_dev: f64,
    );

    // Provided methods
    fn append_scene(&mut self, scene: Scene, scene_transform: Affine) { ... }
    fn draw_image(&mut self, image: ImageBrushRef<'_>, transform: Affine) { ... }
}
Expand description

Abstraction for drawing a 2D scene

Required Methods§

Source

fn reset(&mut self)

Removes all content from the scene

Source

fn push_layer( &mut self, blend: impl Into<BlendMode>, alpha: f32, transform: Affine, clip: &impl Shape, filter: Option<Arc<Filter>>, backdrop_filter: Option<Arc<Filter>>, )

Pushes a new layer clipped by the specified shape and composed with previous layers using the specified blend mode. Every drawing command after this call will be clipped by the shape until the layer is popped. However, the transforms are not saved or modified by the layer stack.

Source

fn push_clip_layer(&mut self, transform: Affine, clip: &impl Shape)

Pushes a new clip layer clipped by the specified shape. Every drawing command after this call will be clipped by the shape until the layer is popped. However, the transforms are not saved or modified by the layer stack.

Source

fn pop_layer(&mut self)

Pops the current layer.

Source

fn stroke<'a>( &mut self, style: &Stroke, transform: Affine, brush: impl Into<PaintRef<'a>>, brush_transform: Option<Affine>, shape: &impl Shape, )

Strokes a shape using the specified style and brush.

Source

fn fill<'a>( &mut self, style: Fill, transform: Affine, brush: impl Into<PaintRef<'a>>, brush_transform: Option<Affine>, shape: &impl Shape, )

Fills a shape using the specified style and brush.

Source

fn draw_glyphs<'a, 's: 'a>( &'s mut self, font: &'a FontData, font_size: f32, hint: bool, normalized_coords: &'a [NormalizedCoord], embolden: Vec2, style: impl Into<StyleRef<'a>>, brush: impl Into<PaintRef<'a>>, brush_alpha: f32, transform: Affine, glyph_transform: Option<Affine>, glyphs: impl Iterator<Item = Glyph> + Clone, )

Draws a run of glyphs

Source

fn draw_box_shadow( &mut self, transform: Affine, rect: Rect, brush: Color, radius: f64, std_dev: f64, )

Draw a rounded rectangle blurred with a gaussian filter.

Provided Methods§

Source

fn append_scene(&mut self, scene: Scene, scene_transform: Affine)

Append a recorded Scene Fragment to the current scene

Source

fn draw_image(&mut self, image: ImageBrushRef<'_>, transform: Affine)

Utility method to draw an image at it’s natural size. For more advanced image drawing use the fill method

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§