Skip to main content

Canvas

Trait Canvas 

Source
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§

Source

fn push_clip(&mut self, rect: Rect)

Clip subsiguiente al rect dado. Stack-discipline: push_clip + draw + pop_clip.

Source

fn pop_clip(&mut self)

Source

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

Rectángulo relleno (sin stroke).

Source

fn stroke_rect(&mut self, rect: Rect, stroke: StrokeStyle)

Rectángulo sólo stroke (sin fill).

Source

fn stroke_line(&mut self, a: Point, b: Point, stroke: StrokeStyle)

Línea de a→b.

Source

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.

Source

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.

Source

fn draw_text(&mut self, p: Point, text: &str, color: Color, size_px: f32)

Glyph de texto sencillo. El layout va a un text-cache dentro del backend; por ahora un trazo simple.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Canvas for PlanRecorder

Source§

impl<'a, 'b> Canvas for GpuSceneCanvas<'a, 'b>

Source§

impl<'a> Canvas for SceneCanvas<'a>