Skip to main content

Canvas

Struct Canvas 

Source
pub struct Canvas<'a> {
    pub w: i32,
    pub h: i32,
    /* private fields */
}

Fields§

§w: i32§h: i32

Implementations§

Source§

impl<'a> Canvas<'a>

Source

pub fn new(px: &'a mut [u32], w: i32, h: i32) -> Self

Wrap a pixel buffer. px.len() must equal w * h.

Source

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

Source

pub fn dim_rect(&mut self, rect: Rect, strength: u32)

Darken already-drawn pixels inside rect to strength/256 of their brightness — a backdrop panel without an alpha channel. 0 blacks out, 256 leaves the pixels untouched.

Source

pub fn draw_rect_outline(&mut self, rect: Rect, color: Color, thickness: i32)

Source

pub fn fill_circle(&mut self, cx: i32, cy: i32, r: i32, color: Color)

Source

pub fn draw_circle_outline( &mut self, cx: i32, cy: i32, r: i32, color: Color, thickness: i32, )

Source

pub fn draw_text( &mut self, x: i32, y: i32, text: &str, color: Color, scale: i32, )

Draw text with the embedded font, top-left of the line box at (x, y). scale multiplies the base text size — pass the monitor’s DPI scale so text is the same visual size on any display.

Source

pub fn draw_shape_rotated( &mut self, shape: &Shape, deg: i32, color: Color, thickness: i32, fill: bool, )

Draw a shape rotated deg about its bbox center. Unrotated shapes and circles take the fast paths; triangles rotate their vertices and reuse the triangle raster; rotated rects raster by inverse-rotating each candidate pixel into the rect’s local space.

Source

pub fn draw_shape( &mut self, shape: &Shape, color: Color, thickness: i32, fill: bool, )

Draw a selection shape as outline or fill.

Source

pub fn draw_segment(&mut self, line: Line, color: Color, thickness: i32)

A bare segment, no end decoration — for lines nobody grabs, like a snap guide. Caps on a short guide read as a box rather than a line, which is the opposite of pointing at something.

Source

pub fn draw_line(&mut self, line: Line, color: Color, thickness: i32)

A measure ruler: the segment plus square end caps, so the two grabbable endpoints are visible against any background.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Canvas<'a>

§

impl<'a> Freeze for Canvas<'a>

§

impl<'a> RefUnwindSafe for Canvas<'a>

§

impl<'a> Send for Canvas<'a>

§

impl<'a> Sync for Canvas<'a>

§

impl<'a> Unpin for Canvas<'a>

§

impl<'a> UnsafeUnpin for Canvas<'a>

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.