Skip to main content

Painter

Struct Painter 

Source
pub struct Painter { /* private fields */ }
Expand description

Draws on a canvas: shapes and text, in points from the top-left corner.

Implementations§

Source§

impl Painter

Source

pub fn width(&self) -> f64

The canvas’s width in points.

Source

pub fn height(&self) -> f64

The canvas’s height in points.

Source

pub fn set_opacity(&mut self, opacity: f64)

The opacity (0–1) of what’s drawn next.

Source

pub fn fill_rect(&mut self, x: f64, y: f64, w: f64, h: f64, color: Color)

Fills a rectangle.

Source

pub fn fill_rounded_rect( &mut self, x: f64, y: f64, w: f64, h: f64, radius: f64, color: Color, )

Fills a rectangle with rounded corners.

Source

pub fn stroke_rect( &mut self, x: f64, y: f64, w: f64, h: f64, color: Color, width: f64, )

Outlines a rectangle.

Source

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

Fills a circle around cx, cy.

Source

pub fn stroke_circle( &mut self, cx: f64, cy: f64, r: f64, color: Color, width: f64, )

Outlines a circle around cx, cy.

Source

pub fn stroke_arc( &mut self, cx: f64, cy: f64, r: f64, degrees: Range<f64>, color: Color, width: f64, )

Part of a circle around cx, cy, clockwise through degrees with 0 at the top, with round ends: progress rings and gauges. stroke_arc(cx, cy, r, 0.0..360.0 * done, ..) is a ring done full.

Source

pub fn line( &mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color, width: f64, )

A straight line.

Source

pub fn polyline(&mut self, points: &[(f64, f64)], color: Color, width: f64)

Lines through points.

Source

pub fn fill_polygon(&mut self, points: &[(f64, f64)], color: Color)

Fills the polygon through points.

Source

pub fn text( &mut self, x: f64, y: f64, text: &str, size: f64, color: Color, align: Align, )

Text in the system font at size points. x is its start, centre or end (align); y is its top.

Source

pub fn bold_text( &mut self, x: f64, y: f64, text: &str, size: f64, color: Color, align: Align, )

Bold text (see text).

Source

pub fn measure(&self, text: &str, size: f64) -> (f64, f64)

The width and height of text at size points.

Auto Trait Implementations§

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> AutoreleaseSafe for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.