pub trait Shapes {
type Ink: Copy;
// Required methods
fn stroke_rect(&mut self, area: Area, ink: Self::Ink);
fn fill_rect(&mut self, area: Area, ink: Self::Ink);
fn line(&mut self, from: (i32, i32), to: (i32, i32), ink: Self::Ink);
fn bar(
&mut self,
area: Area,
fraction: f32,
fill: Self::Ink,
track: Self::Ink,
);
fn rounded_rect(&mut self, area: Area, radius: u32, ink: Self::Ink);
fn fill_rounded_rect(&mut self, area: Area, radius: u32, ink: Self::Ink);
fn circle(&mut self, centre: (f32, f32), radius: f32, ink: Self::Ink);
fn fill_circle(&mut self, centre: (f32, f32), radius: f32, ink: Self::Ink);
fn label(&mut self, x: i32, y: i32, text: &str, ink: Self::Ink) -> u32;
}Expand description
Shapes both surface models draw. Ink is what paints: a style for
cells, a colour for pixels.
Required Associated Types§
Required Methods§
Sourcefn stroke_rect(&mut self, area: Area, ink: Self::Ink)
fn stroke_rect(&mut self, area: Area, ink: Self::Ink)
A one-unit outline of area.
Sourcefn line(&mut self, from: (i32, i32), to: (i32, i32), ink: Self::Ink)
fn line(&mut self, from: (i32, i32), to: (i32, i32), ink: Self::Ink)
A line from from to to, both ends included.
Sourcefn bar(&mut self, area: Area, fraction: f32, fill: Self::Ink, track: Self::Ink)
fn bar(&mut self, area: Area, fraction: f32, fill: Self::Ink, track: Self::Ink)
A horizontal bar across area: the left fraction (0 to 1) in
fill, the rest in track. Partial units are shown with eighth
blocks (cells) or coverage (pixels).
Sourcefn rounded_rect(&mut self, area: Area, radius: u32, ink: Self::Ink)
fn rounded_rect(&mut self, area: Area, radius: u32, ink: Self::Ink)
The outline of area with corners of radius (cells round their
corners with arcs whatever the radius; a zero radius is square).
Sourcefn fill_rounded_rect(&mut self, area: Area, radius: u32, ink: Self::Ink)
fn fill_rounded_rect(&mut self, area: Area, radius: u32, ink: Self::Ink)
area filled, with corners of radius.
Sourcefn circle(&mut self, centre: (f32, f32), radius: f32, ink: Self::Ink)
fn circle(&mut self, centre: (f32, f32), radius: f32, ink: Self::Ink)
A circle’s outline around centre, in continuous coordinates: the
unit at (x, y) spans x..x + 1, so (x + 0.5, y + 0.5) is its
centre, and a moving shape can sit between units (pixels antialias
it; cells round to the nearest cell). Cells are about twice as tall
as wide, so in cells the radius counts rows and spans twice as many
columns.
Sourcefn fill_circle(&mut self, centre: (f32, f32), radius: f32, ink: Self::Ink)
fn fill_circle(&mut self, centre: (f32, f32), radius: f32, ink: Self::Ink)
A filled circle (see Shapes::circle).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".