pub struct StrokeInputBatch { /* private fields */ }Expand description
An ordered run of StrokeInputs.
Ink validates the whole batch up front: times must not go backwards, every input must report the same tool type, and the optional fields must be present on all of them or none.
Implementations§
Source§impl StrokeInputBatch
impl StrokeInputBatch
Sourcepub fn new(inputs: &[StrokeInput]) -> Result<Self>
pub fn new(inputs: &[StrokeInput]) -> Result<Self>
Builds a batch from a slice of inputs.
Sourcepub fn with_seed(
inputs: &[StrokeInput],
noise_seed: u32,
base_paint_animation_phase: f32,
) -> Result<Self>
pub fn with_seed( inputs: &[StrokeInput], noise_seed: u32, base_paint_animation_phase: f32, ) -> Result<Self>
Builds a batch, choosing the seed for brushes with randomised noise and the starting phase for animated brush paints.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get(&self, index: usize) -> Option<StrokeInput>
pub fn get(&self, index: usize) -> Option<StrokeInput>
The input at index, or None if it is past the end.
Sourcepub fn push(&mut self, input: StrokeInput) -> Result<()>
pub fn push(&mut self, input: StrokeInput) -> Result<()>
Appends one input, which must be consistent with what is already here.
Sourcepub fn extend_from_batch(&mut self, other: &StrokeInputBatch) -> Result<()>
pub fn extend_from_batch(&mut self, other: &StrokeInputBatch) -> Result<()>
Appends another batch.
pub fn clear(&mut self)
Sourcepub fn duration(&self) -> Duration
pub fn duration(&self) -> Duration
Time from the first input to the last.
Ink keeps times as f32 seconds, so this does not round-trip exactly:
a batch built from 112ms of input reads back as 112.000003ms. Compare
with a tolerance rather than for equality.
Sourcepub fn noise_seed(&self) -> u32
pub fn noise_seed(&self) -> u32
The seed used by brushes with randomised behaviour.
Sourcepub fn iter(&self) -> impl Iterator<Item = StrokeInput> + '_
pub fn iter(&self) -> impl Iterator<Item = StrokeInput> + '_
Iterates over the inputs, copying each one out as it goes.