MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / screen_to_render

Method screen_to_render

src/camera.rs:128–135  ·  view source on GitHub ↗

Convert screen coordinates to render coordinates (without offset)

(&self, screen_pos: DVec2, screen_size: DVec2)

Source from the content-addressed store, hash-verified

126
127 /// Convert screen coordinates to render coordinates (without offset)
128 pub fn screen_to_render(&self, screen_pos: DVec2, screen_size: DVec2) -> DVec2 {
129 let ndc_x = (screen_pos.x / screen_size.x) * 2.0 - 1.0;
130 let ndc_y = -((screen_pos.y / screen_size.y) * 2.0 - 1.0); // Flip Y
131 DVec2::new(
132 self.effective_position().x + ndc_x * self.half_extents.x,
133 self.effective_position().y + ndc_y * self.half_extents.y,
134 )
135 }
136
137 /// Set camera bounds without changing the render offset
138 pub fn set_bounds_preserve_offset(

Callers 2

handle_mouse_eventMethod · 0.80
zoom_at_cursorMethod · 0.80

Calls 2

effective_positionMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected