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§
Sourcefn 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_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.
Sourcefn push_clip_layer(&mut self, transform: Affine, clip: &impl Shape)
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.
Sourcefn stroke<'a>(
&mut self,
style: &Stroke,
transform: Affine,
brush: impl Into<PaintRef<'a>>,
brush_transform: Option<Affine>,
shape: &impl Shape,
)
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.
Sourcefn fill<'a>(
&mut self,
style: Fill,
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, )
Fills a shape using the specified style and brush.
Sourcefn 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_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
Provided Methods§
Sourcefn append_scene(&mut self, scene: Scene, scene_transform: Affine)
fn append_scene(&mut self, scene: Scene, scene_transform: Affine)
Append a recorded Scene Fragment to the current scene
Sourcefn draw_image(&mut self, image: ImageBrushRef<'_>, transform: Affine)
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".