cranpose_platform_web/
lib.rs1#![deny(missing_docs)]
2#![doc = include_str!("../README.md")]
3
4use cranpose_foundation::{PointerEvent, PointerEventKind};
5use cranpose_ui_graphics::Point;
6
7pub struct WebPlatform {
9 scale_factor: f64,
10}
11
12impl WebPlatform {
13 pub fn new(scale_factor: f64) -> Self {
15 Self { scale_factor }
16 }
17
18 pub fn set_scale_factor(&mut self, factor: f64) {
22 self.scale_factor = factor;
23 }
24
25 pub fn pointer_position(&self, x: f64, y: f64) -> Point {
29 Point {
30 x: x as f32,
31 y: y as f32,
32 }
33 }
34
35 pub fn pointer_event(&self, kind: PointerEventKind, x: f64, y: f64) -> PointerEvent {
39 let logical = self.pointer_position(x, y);
40 PointerEvent::new(kind, logical, logical)
41 }
42}
43
44impl Default for WebPlatform {
45 fn default() -> Self {
46 Self::new(1.0)
47 }
48}