Skip to main content

DrawCtx

Struct DrawCtx 

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

What a crate::Custom node draws into. Coordinates are the node’s own: the origin is the node center, positive x is right, positive y is down.

The closure runs every time the frame is painted. It has to be a function of t, of signals it captured, and of DrawCtx::rng: the same inputs must produce the same shapes, because a frame can be painted more than once and a seek paints it without the frames in between.

Implementations§

Source§

impl DrawCtx

Source

pub fn time(&self) -> f64

Time of the frame being painted, in seconds.

Source

pub fn size(&self) -> (f64, f64)

The node’s box, in its own coordinates.

Source

pub fn quality(&self) -> f64

1 is a full frame. A later draft mode will pass a smaller value so a closure can draw fewer shapes; it does not change positions.

Source

pub fn rng(&self, seed: u64) -> DrawRng

Generator for seed. It does not touch the scene’s random(), and the same seed is the same sequence on every paint of this frame.

Source

pub fn line(&mut self, a: impl Into<Point>, b: impl Into<Point>) -> Pen<'_>

A straight segment from a to b.

Source

pub fn circle(&mut self, center: impl Into<Point>, radius: f64) -> Pen<'_>

A filled or stroked circle.

Source

pub fn rect(&mut self, rect: Rect) -> Pen<'_>

A rectangle in the node’s coordinates.

Source

pub fn path(&mut self, path: BezPath) -> Pen<'_>

An arbitrary outline.

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V