Spaces:
Running
Running
Download rust/src/utils/remap.rs from allnewthunder/rust-sandbox: direct link, hf CLI and curl.
- Browser
- Download file 235 Bytes
-
https://huggingface.co/spaces/allnewthunder/rust-sandbox/resolve/main/rust/src/utils/remap.rs
- Command line
-
hf download hf://spaces/allnewthunder/rust-sandbox/rust/src/utils/remap.rs
-
curl -L -o remap.rs https://huggingface.co/spaces/allnewthunder/rust-sandbox/resolve/main/rust/src/utils/remap.rs
235 Bytes
| use bevy::math::Vec2; | |
| pub fn remap_cursor_position(pos: Vec2, from: [f32; 2], to: [usize; 2]) -> Vec2 { | |
| let new_x = (pos.x / from[0]) * to[0] as f32; | |
| let new_y = (pos.y / from[1]) * to[1] as f32; | |
| Vec2::new(new_x, new_y) | |
| } | |