Skip to main content

Shapes

Trait Shapes 

Source
pub trait Shapes {
    // Required methods
    fn size(&self) -> (i64, i64);
    fn put(&mut self, x: i64, y: i64, colour: Rgb);

    // Provided methods
    fn line(&mut self, x0: i64, y0: i64, x1: i64, y1: i64, colour: Rgb) { ... }
    fn rect(&mut self, x: i64, y: i64, w: i64, h: i64, colour: Rgb) { ... }
    fn fill_rect(&mut self, x: i64, y: i64, w: i64, h: i64, colour: Rgb) { ... }
    fn circle(&mut self, cx: i64, cy: i64, r: i64, colour: Rgb) { ... }
    fn fill_circle(&mut self, cx: i64, cy: i64, r: i64, colour: Rgb) { ... }
    fn plot(&mut self, f: impl Fn(f64) -> f64, colour: Rgb)
       where Self: Sized { ... }
}
Expand description

Lines, rectangles and circles, for anything that can set a point.

Required Methods§

Source

fn size(&self) -> (i64, i64)

Size in points.

Source

fn put(&mut self, x: i64, y: i64, colour: Rgb)

Sets one point; outside the surface it does nothing.

Provided Methods§

Source

fn line(&mut self, x0: i64, y0: i64, x1: i64, y1: i64, colour: Rgb)

Source

fn rect(&mut self, x: i64, y: i64, w: i64, h: i64, colour: Rgb)

Source

fn fill_rect(&mut self, x: i64, y: i64, w: i64, h: i64, colour: Rgb)

Source

fn circle(&mut self, cx: i64, cy: i64, r: i64, colour: Rgb)

Source

fn fill_circle(&mut self, cx: i64, cy: i64, r: i64, colour: Rgb)

Source

fn plot(&mut self, f: impl Fn(f64) -> f64, colour: Rgb)
where Self: Sized,

f from 0 to 1 across the width, with -1 at the bottom and 1 at the top, joined so steep parts have no gaps.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Shapes for Dots<'_>

Source§

impl Shapes for Pixels<'_>