pub trait Canvas {
// Required methods
fn push_clip(&mut self, rect: Rect);
fn pop_clip(&mut self);
fn fill_rect(&mut self, rect: Rect, color: Color);
fn stroke_rect(&mut self, rect: Rect, stroke: StrokeStyle);
fn stroke_line(&mut self, a: Point, b: Point, stroke: StrokeStyle);
fn stroke_polyline(&mut self, coords: &[f32], stroke: StrokeStyle);
fn fill_triangle_strip(&mut self, coords: &[f32], colors: &[Color]);
fn draw_text(&mut self, p: Point, text: &str, color: Color, size_px: f32);
}Required Methods§
Sourcefn push_clip(&mut self, rect: Rect)
fn push_clip(&mut self, rect: Rect)
Clip subsiguiente al rect dado. Stack-discipline:
push_clip + draw + pop_clip.
fn pop_clip(&mut self)
Sourcefn stroke_rect(&mut self, rect: Rect, stroke: StrokeStyle)
fn stroke_rect(&mut self, rect: Rect, stroke: StrokeStyle)
Rectángulo sólo stroke (sin fill).
Sourcefn stroke_line(&mut self, a: Point, b: Point, stroke: StrokeStyle)
fn stroke_line(&mut self, a: Point, b: Point, stroke: StrokeStyle)
Línea de a→b.
Sourcefn stroke_polyline(&mut self, coords: &[f32], stroke: StrokeStyle)
fn stroke_polyline(&mut self, coords: &[f32], stroke: StrokeStyle)
Polilínea sobre coords interleaved [x0,y0,x1,y1,…].
El backend la rendea como un solo draw call cuando puede.
Sourcefn fill_triangle_strip(&mut self, coords: &[f32], colors: &[Color])
fn fill_triangle_strip(&mut self, coords: &[f32], colors: &[Color])
Triangle strip rellenado, con un color por vértice
(longitudes deben coincidir: coords.len()/2 == colors.len()).
Es lo que usa el phosphor trail y los ribbons Sankey.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".