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

Method set_bounds_preserve_offset

src/camera.rs:138–150  ·  view source on GitHub ↗

Set camera bounds without changing the render offset

(
        &mut self,
        bounds_min: DVec2,
        bounds_max: DVec2,
        padding_frac: f64,
    )

Source from the content-addressed store, hash-verified

136
137 /// Set camera bounds without changing the render offset
138 pub fn set_bounds_preserve_offset(
139 &mut self,
140 bounds_min: DVec2,
141 bounds_max: DVec2,
142 padding_frac: f64,
143 ) {
144 let size = (bounds_max - bounds_min).max(DVec2::splat(EPSILON_SMALL));
145 let size_padded = size + size * padding_frac;
146 self.half_extents = size_padded / 2.0;
147 let center = (bounds_min + bounds_max) / 2.0;
148 self.position = center;
149 // Keep the existing render_offset
150 }
151
152 pub(crate) fn set_bounds(&mut self, bounds_min: DVec2, bounds_max: DVec2, padding_frac: f64) {
153 let size = (bounds_max - bounds_min).max(DVec2::splat(EPSILON_SMALL));

Callers 1

handle_mouse_eventMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected