cranpose_platform_web/
lib.rs1use cranpose_foundation::{PointerEvent, PointerEventKind};
2use cranpose_ui_graphics::Point;
3
4pub struct WebPlatform {
5 scale_factor: f64,
6}
7
8impl WebPlatform {
9 pub fn new(scale_factor: f64) -> Self {
10 Self { scale_factor }
11 }
12
13 pub fn set_scale_factor(&mut self, factor: f64) {
14 self.scale_factor = factor;
15 }
16
17 pub fn pointer_position(&self, x: f64, y: f64) -> Point {
18 Point {
19 x: x as f32,
20 y: y as f32,
21 }
22 }
23
24 pub fn pointer_event(&self, kind: PointerEventKind, x: f64, y: f64) -> PointerEvent {
25 let logical = self.pointer_position(x, y);
26 PointerEvent::new(kind, logical, logical)
27 }
28}
29
30impl Default for WebPlatform {
31 fn default() -> Self {
32 Self::new(1.0)
33 }
34}