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