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
impl InProgressStroke
pub fn new() -> Self
Sourcepub fn start(&mut self, brush: &Brush)
pub fn start(&mut self, brush: &Brush)
Begins a stroke with brush, discarding whatever was in progress.
Sourcepub fn start_with_seed(
&mut self,
brush: &Brush,
noise_seed: u32,
base_animation_phase: f32,
)
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.
Sourcepub fn enqueue_inputs(
&mut self,
real: &StrokeInputBatch,
predicted: Option<&StrokeInputBatch>,
) -> Result<()>
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.
Sourcepub fn finish_inputs(&mut self)
pub fn finish_inputs(&mut self)
Says no more input is coming.
Sourcepub fn update_shape(&mut self, elapsed: Duration) -> Result<()>
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.
Sourcepub fn needs_update(&self) -> bool
pub fn needs_update(&self) -> bool
Whether queued input or time-varying behaviour means the geometry is stale.
pub fn inputs_are_finished(&self) -> bool
Sourcepub fn changes_with_time(&self) -> bool
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.
Sourcepub fn coat_count(&self) -> u32
pub fn coat_count(&self) -> u32
Number of coats the current brush paints, and so the number of meshes.
Sourcepub fn input_count(&self) -> usize
pub fn input_count(&self) -> usize
Inputs processed so far, real and predicted.
Sourcepub fn real_input_count(&self) -> usize
pub fn real_input_count(&self) -> usize
Of those, how many were real rather than predicted.
Sourcepub fn coat_mesh(&self, coat_index: u32) -> Mesh
pub fn coat_mesh(&self, coat_index: u32) -> Mesh
Current geometry for one coat. An out-of-range coat gives an empty mesh.
Sourcepub fn coat_bounds(&self, coat_index: u32) -> Option<Rect>
pub fn coat_bounds(&self, coat_index: u32) -> Option<Rect>
Bounding box of one coat, or None when it has no geometry yet.