Skip to main content

RendererPrimitives

Struct RendererPrimitives 

Source
pub struct RendererPrimitives<'a, PF: PixelFormat> { /* private fields */ }
Expand description

Basic shape primitives renderer.

Draws rectangles, ellipses, and Bresenham lines directly into a RendererBase without anti-aliasing. Maintains separate fill and line colors and a current position for line_to operations.

Port of C++ renderer_primitives<BaseRenderer>.

Implementations§

Source§

impl<'a, PF: PixelFormat> RendererPrimitives<'a, PF>
where PF::ColorType: Default + Clone,

Source

pub fn new(ren: &'a mut RendererBase<PF>) -> Self

Source

pub fn coord(c: f64) -> i32

Convert a floating-point coordinate to subpixel Bresenham coordinate.

Source

pub fn set_fill_color(&mut self, c: PF::ColorType)

Source

pub fn set_line_color(&mut self, c: PF::ColorType)

Source

pub fn fill_color(&self) -> &PF::ColorType

Source

pub fn line_color(&self) -> &PF::ColorType

Source

pub fn rectangle(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)

Draw an outlined rectangle (line color only).

Source

pub fn solid_rectangle(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)

Draw a solid filled rectangle (fill color only).

Source

pub fn outlined_rectangle(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)

Draw an outlined and filled rectangle.

Source

pub fn ellipse(&mut self, x: i32, y: i32, rx: i32, ry: i32)

Draw an outlined ellipse (line color only).

Source

pub fn solid_ellipse(&mut self, x: i32, y: i32, rx: i32, ry: i32)

Draw a solid filled ellipse (fill color only).

Source

pub fn outlined_ellipse(&mut self, x: i32, y: i32, rx: i32, ry: i32)

Draw an outlined and filled ellipse.

Source

pub fn line(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, last: bool)

Draw a Bresenham line from (x1,y1) to (x2,y2).

Coordinates are in subpixel units (use coord() to convert).

Source

pub fn move_to(&mut self, x: i32, y: i32)

Set the current position for line_to.

Source

pub fn line_to(&mut self, x: i32, y: i32, last: bool)

Draw a line from the current position to (x, y).

Source

pub fn ren(&self) -> &RendererBase<PF>

Source

pub fn ren_mut(&mut self) -> &mut RendererBase<PF>

Trait Implementations§

Source§

impl<'a, PF: PixelFormat> RendererPrimitivesLike for RendererPrimitives<'a, PF>
where PF::ColorType: Default + Clone,

Source§

type Color = <PF as PixelFormat>::ColorType

Source§

fn coord(c: f64) -> i32

Source§

fn move_to(&mut self, x: i32, y: i32)

Source§

fn line_to(&mut self, x: i32, y: i32, last: bool)

Source§

fn set_line_color(&mut self, c: Self::Color)

Auto Trait Implementations§

§

impl<'a, PF> Freeze for RendererPrimitives<'a, PF>
where <PF as PixelFormat>::ColorType: Freeze,

§

impl<'a, PF> RefUnwindSafe for RendererPrimitives<'a, PF>

§

impl<'a, PF> Send for RendererPrimitives<'a, PF>
where <PF as PixelFormat>::ColorType: Send, PF: Send,

§

impl<'a, PF> Sync for RendererPrimitives<'a, PF>
where <PF as PixelFormat>::ColorType: Sync, PF: Sync,

§

impl<'a, PF> Unpin for RendererPrimitives<'a, PF>
where <PF as PixelFormat>::ColorType: Unpin,

§

impl<'a, PF> !UnwindSafe for RendererPrimitives<'a, PF>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.