Skip to main content

Canvas

Trait Canvas 

Source
pub trait Canvas {
Show 13 methods // Required methods fn fill_rect(&mut self, rect: Rect, color: Color); fn stroke_rect(&mut self, rect: Rect, color: Color, width: f32); fn draw_text(&mut self, text: &str, position: Point, style: &TextStyle); fn draw_line(&mut self, from: Point, to: Point, color: Color, width: f32); fn fill_circle(&mut self, center: Point, radius: f32, color: Color); fn stroke_circle( &mut self, center: Point, radius: f32, color: Color, width: f32, ); fn fill_arc( &mut self, center: Point, radius: f32, start_angle: f32, end_angle: f32, color: Color, ); fn draw_path(&mut self, points: &[Point], color: Color, width: f32); fn fill_polygon(&mut self, points: &[Point], color: Color); fn push_clip(&mut self, rect: Rect); fn pop_clip(&mut self); fn push_transform(&mut self, transform: Transform2D); fn pop_transform(&mut self);
}
Expand description

Canvas trait for paint operations.

This is a minimal abstraction over the rendering backend.

Required Methods§

Source

fn fill_rect(&mut self, rect: Rect, color: Color)

Draw a filled rectangle.

Source

fn stroke_rect(&mut self, rect: Rect, color: Color, width: f32)

Draw a stroked rectangle.

Source

fn draw_text(&mut self, text: &str, position: Point, style: &TextStyle)

Draw text.

Source

fn draw_line(&mut self, from: Point, to: Point, color: Color, width: f32)

Draw a line between two points.

Source

fn fill_circle(&mut self, center: Point, radius: f32, color: Color)

Draw a filled circle.

Source

fn stroke_circle( &mut self, center: Point, radius: f32, color: Color, width: f32, )

Draw a stroked circle.

Source

fn fill_arc( &mut self, center: Point, radius: f32, start_angle: f32, end_angle: f32, color: Color, )

Draw a filled arc (pie slice).

Source

fn draw_path(&mut self, points: &[Point], color: Color, width: f32)

Draw a path (polyline).

Source

fn fill_polygon(&mut self, points: &[Point], color: Color)

Fill a polygon.

Source

fn push_clip(&mut self, rect: Rect)

Push a clip region.

Source

fn pop_clip(&mut self)

Pop the clip region.

Source

fn push_transform(&mut self, transform: Transform2D)

Push a transform.

Source

fn pop_transform(&mut self)

Pop the transform.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Canvas for HeadlessCanvas

Source§

fn fill_rect(&mut self, rect: Rect, color: Color)

Source§

fn stroke_rect(&mut self, rect: Rect, color: Color, _width: f32)

Source§

fn draw_text(&mut self, text: &str, position: Point, style: &TextStyle)

Source§

fn draw_line(&mut self, from: Point, to: Point, color: Color, _width: f32)

Source§

fn fill_circle(&mut self, center: Point, radius: f32, color: Color)

Source§

fn stroke_circle( &mut self, center: Point, radius: f32, color: Color, _width: f32, )

Source§

fn fill_arc( &mut self, _center: Point, _radius: f32, _start: f32, _end: f32, _color: Color, )

Source§

fn draw_path(&mut self, points: &[Point], color: Color, width: f32)

Source§

fn fill_polygon(&mut self, _points: &[Point], _color: Color)

Source§

fn push_clip(&mut self, _rect: Rect)

Source§

fn pop_clip(&mut self)

Source§

fn push_transform(&mut self, _transform: Transform2D)

Source§

fn pop_transform(&mut self)

Implementors§