pub struct StrokeInput {
pub tool_type: ToolType,
pub position: Point,
pub elapsed_time: Duration,
pub stroke_unit_length_cm: Option<f32>,
pub pressure: Option<f32>,
pub tilt: Option<f32>,
pub orientation: Option<f32>,
pub barrel_twist: Option<f32>,
}Expand description
One sampled input event.
Every field but tool_type, position and elapsed_time is optional, and
all the inputs in a batch have to agree on which ones are present. Mixing,
say, some events with pressure and some without is rejected when the batch
is built.
Fields§
§tool_type: ToolTypeWhat produced the event.
position: PointWhere it happened, in stroke units.
elapsed_time: DurationTime since the start of the stroke.
stroke_unit_length_cm: Option<f32>How long one stroke unit is, in centimetres. Needed by brush behaviours that work in physical units.
pressure: Option<f32>Stylus or touch pressure, normally in 0.0..=1.0.
tilt: Option<f32>Stylus tilt away from perpendicular, in radians.
orientation: Option<f32>Direction the stylus is tilted towards, in radians.
barrel_twist: Option<f32>Rotation of the stylus about its own axis, in radians.
Implementations§
Source§impl StrokeInput
impl StrokeInput
Sourcepub fn new(tool_type: ToolType, position: Point, elapsed_time: Duration) -> Self
pub fn new(tool_type: ToolType, position: Point, elapsed_time: Duration) -> Self
The minimum an input needs: where and when.
Sourcepub fn with_pressure(self, pressure: f32) -> Self
pub fn with_pressure(self, pressure: f32) -> Self
Adds pressure to an input.
Sourcepub fn with_tilt_orientation(self, tilt: f32, orientation: f32) -> Self
pub fn with_tilt_orientation(self, tilt: f32, orientation: f32) -> Self
Adds stylus tilt and orientation, both in radians.
Trait Implementations§
Source§impl Clone for StrokeInput
impl Clone for StrokeInput
Source§fn clone(&self) -> StrokeInput
fn clone(&self) -> StrokeInput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StrokeInput
Source§impl Debug for StrokeInput
impl Debug for StrokeInput
Source§impl Default for StrokeInput
impl Default for StrokeInput
Source§fn default() -> StrokeInput
fn default() -> StrokeInput
Source§impl PartialEq for StrokeInput
impl PartialEq for StrokeInput
Source§fn eq(&self, other: &StrokeInput) -> bool
fn eq(&self, other: &StrokeInput) -> bool
self and other values to be equal, and is used by ==.