cranpose_platform_web/
lib.rs1#![doc = include_str!("../README.md")]
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 {
21 x: x as f32,
22 y: y as f32,
23 }
24 }
25
26 pub fn pointer_event(&self, kind: PointerEventKind, x: f64, y: f64) -> PointerEvent {
27 let logical = self.pointer_position(x, y);
28 PointerEvent::new(kind, logical, logical)
29 }
30}
31
32impl Default for WebPlatform {
33 fn default() -> Self {
34 Self::new(1.0)
35 }
36}