Skip to main content

InProgressStroke

Struct InProgressStroke 

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

A stroke being drawn.

The usual loop is start, then enqueue_inputs and update_shape as events arrive and frames are drawn, then finish_inputs when the user lifts the pen and to_stroke to keep the result.

Geometry is read back per brush coat with coat_mesh. A brush with several coats produces one mesh per coat, drawn in order.

Implementations§

Source§

impl InProgressStroke

Source

pub fn new() -> Self

Source

pub fn clear(&mut self)

Throws away any stroke in progress.

Source

pub fn start(&mut self, brush: &Brush)

Begins a stroke with brush, discarding whatever was in progress.

Source

pub fn start_with_seed( &mut self, brush: &Brush, noise_seed: u32, base_animation_phase: f32, )

Begins a stroke, choosing the noise seed and the starting phase for animated brush paints.

Source

pub fn enqueue_inputs( &mut self, real: &StrokeInputBatch, predicted: Option<&StrokeInputBatch>, ) -> Result<()>

Queues newly arrived input.

predicted is input the platform expects but has not confirmed, used to hide latency; it is replaced wholesale on the next call rather than accumulated. Pass None when there is no prediction.

Source

pub fn finish_inputs(&mut self)

Says no more input is coming.

Source

pub fn update_shape(&mut self, elapsed: Duration) -> Result<()>

Regenerates geometry up to elapsed, measured from the start of the stroke. Must not go backwards between calls.

Source

pub fn needs_update(&self) -> bool

Whether queued input or time-varying behaviour means the geometry is stale.

Source

pub fn inputs_are_finished(&self) -> bool

Source

pub fn changes_with_time(&self) -> bool

Whether the brush keeps changing the shape as time passes, which means update_shape has to keep being called even after input stops.

Source

pub fn coat_count(&self) -> u32

Number of coats the current brush paints, and so the number of meshes.

Source

pub fn input_count(&self) -> usize

Inputs processed so far, real and predicted.

Source

pub fn real_input_count(&self) -> usize

Of those, how many were real rather than predicted.

Source

pub fn coat_mesh(&self, coat_index: u32) -> Mesh

Current geometry for one coat. An out-of-range coat gives an empty mesh.

Source

pub fn coat_bounds(&self, coat_index: u32) -> Option<Rect>

Bounding box of one coat, or None when it has no geometry yet.

Source

pub fn to_stroke(&self) -> Stroke

Copies the current state into a finished Stroke, leaving this builder alone so drawing can carry on.

Trait Implementations§

Source§

impl Debug for InProgressStroke

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InProgressStroke

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for InProgressStroke

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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