Skip to main content

DrawScope

Trait DrawScope 

Source
pub trait DrawScope {
Show 22 methods // Required methods fn size(&self) -> Size; fn draw_content(&mut self); fn draw_rect(&mut self, brush: Brush); fn draw_rect_blend(&mut self, brush: Brush, blend_mode: BlendMode); fn draw_rect_at(&mut self, rect: Rect, brush: Brush); fn draw_rect_at_blend( &mut self, rect: Rect, brush: Brush, blend_mode: BlendMode, ); fn draw_round_rect(&mut self, brush: Brush, radii: CornerRadii); fn draw_round_rect_blend( &mut self, brush: Brush, radii: CornerRadii, blend_mode: BlendMode, ); fn draw_round_rect_at( &mut self, rect: Rect, brush: Brush, radii: CornerRadii, ); fn draw_circle(&mut self, brush: Brush, center: Point, radius: f32); fn draw_circle_blend( &mut self, brush: Brush, center: Point, radius: f32, blend_mode: BlendMode, ); fn draw_image(&mut self, image: ImageBitmap); fn draw_image_blend(&mut self, image: ImageBitmap, blend_mode: BlendMode); fn draw_image_at( &mut self, rect: Rect, image: ImageBitmap, alpha: f32, color_filter: Option<ColorFilter>, ); fn draw_image_at_sampled( &mut self, rect: Rect, image: ImageBitmap, alpha: f32, color_filter: Option<ColorFilter>, sampling: ImageSampling, ); fn draw_image_at_blend( &mut self, rect: Rect, image: ImageBitmap, alpha: f32, color_filter: Option<ColorFilter>, blend_mode: BlendMode, ); fn draw_image_src( &mut self, image: ImageBitmap, src_rect: Rect, dst_rect: Rect, alpha: f32, color_filter: Option<ColorFilter>, ); fn draw_image_src_sampled( &mut self, image: ImageBitmap, src_rect: Rect, dst_rect: Rect, alpha: f32, color_filter: Option<ColorFilter>, sampling: ImageSampling, ); fn draw_image_src_blend( &mut self, image: ImageBitmap, src_rect: Rect, dst_rect: Rect, alpha: f32, color_filter: Option<ColorFilter>, blend_mode: BlendMode, ); fn draw_vector_path(&mut self, path: &VectorPath, brush: Brush); fn into_primitives(self) -> Vec<DrawPrimitive>; // Provided method fn draw_svg_path(&mut self, d: &str, brush: Brush) { ... }
}

Required Methods§

Source

fn size(&self) -> Size

Source

fn draw_content(&mut self)

Source

fn draw_rect(&mut self, brush: Brush)

Source

fn draw_rect_blend(&mut self, brush: Brush, blend_mode: BlendMode)

Source

fn draw_rect_at(&mut self, rect: Rect, brush: Brush)

Draws a rectangle at the specified position and size.

Source

fn draw_rect_at_blend( &mut self, rect: Rect, brush: Brush, blend_mode: BlendMode, )

Source

fn draw_round_rect(&mut self, brush: Brush, radii: CornerRadii)

Source

fn draw_round_rect_blend( &mut self, brush: Brush, radii: CornerRadii, blend_mode: BlendMode, )

Source

fn draw_round_rect_at(&mut self, rect: Rect, brush: Brush, radii: CornerRadii)

Draws a rounded rectangle at the specified position and size.

Source

fn draw_circle(&mut self, brush: Brush, center: Point, radius: f32)

Source

fn draw_circle_blend( &mut self, brush: Brush, center: Point, radius: f32, blend_mode: BlendMode, )

Source

fn draw_image(&mut self, image: ImageBitmap)

Source

fn draw_image_blend(&mut self, image: ImageBitmap, blend_mode: BlendMode)

Source

fn draw_image_at( &mut self, rect: Rect, image: ImageBitmap, alpha: f32, color_filter: Option<ColorFilter>, )

Source

fn draw_image_at_sampled( &mut self, rect: Rect, image: ImageBitmap, alpha: f32, color_filter: Option<ColorFilter>, sampling: ImageSampling, )

Source

fn draw_image_at_blend( &mut self, rect: Rect, image: ImageBitmap, alpha: f32, color_filter: Option<ColorFilter>, blend_mode: BlendMode, )

Source

fn draw_image_src( &mut self, image: ImageBitmap, src_rect: Rect, dst_rect: Rect, alpha: f32, color_filter: Option<ColorFilter>, )

Draws a sub-region of an image. src_rect is in image-pixel coordinates; dst_rect is in scope coordinates.

Source

fn draw_image_src_sampled( &mut self, image: ImageBitmap, src_rect: Rect, dst_rect: Rect, alpha: f32, color_filter: Option<ColorFilter>, sampling: ImageSampling, )

Source

fn draw_image_src_blend( &mut self, image: ImageBitmap, src_rect: Rect, dst_rect: Rect, alpha: f32, color_filter: Option<ColorFilter>, blend_mode: BlendMode, )

Source

fn draw_vector_path(&mut self, path: &VectorPath, brush: Brush)

Fills a parsed SVG path in scope coordinates (path units are dp).

The fill is rasterized on the CPU into a supersampled, anti-aliased bitmap covering the path bounds and drawn as an image primitive, so it works on every render backend. Parse the path once with crate::VectorPath::parse and redraw it per frame. Solid brushes are honored exactly; gradient brushes currently fall back to their first stop color.

Source

fn into_primitives(self) -> Vec<DrawPrimitive>

Provided Methods§

Source

fn draw_svg_path(&mut self, d: &str, brush: Brush)

Parses SVG path data (the d attribute syntax: M/m L/l H/h V/v C/c S/s Q/q T/t A/a Z/z) and fills it. Invalid path data draws nothing. Prefer crate::VectorPath::parse + draw_vector_path to avoid re-parsing and to surface parse errors.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§