pub struct WebPlatform { /* private fields */ }Expand description
Converts browser pointer input into Cranpose pointer events.
Implementations§
Source§impl WebPlatform
impl WebPlatform
Sourcepub fn new(scale_factor: f64) -> Self
pub fn new(scale_factor: f64) -> Self
Creates a platform adapter for a canvas with the given device pixel ratio.
Sourcepub fn set_scale_factor(&mut self, factor: f64)
pub fn set_scale_factor(&mut self, factor: f64)
Sets the device pixel ratio of the canvas.
Pointer positions are not scaled by it, because browser events use CSS pixels.
Sourcepub fn pointer_position(&self, x: f64, y: f64) -> Point
pub fn pointer_position(&self, x: f64, y: f64) -> Point
Returns the canvas position x, y as a Point in logical pixels.
Browser events already use CSS pixels, so the position is not scaled.
Sourcepub fn pointer_event(
&self,
kind: PointerEventKind,
x: f64,
y: f64,
) -> PointerEvent
pub fn pointer_event( &self, kind: PointerEventKind, x: f64, y: f64, ) -> PointerEvent
Builds a pointer event of kind at a canvas position given in CSS pixels.
The event carries the same position as its local and its root position.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebPlatform
impl RefUnwindSafe for WebPlatform
impl Send for WebPlatform
impl Sync for WebPlatform
impl Unpin for WebPlatform
impl UnsafeUnpin for WebPlatform
impl UnwindSafe for WebPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more