add set_plot_bounds method, giving users the ability to set the plot bounds themselves. (#2320)
* add set_plot_bounds method * call it from_min_max for consistency with Rect Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
parent
bde47c9957
commit
f3633534e7
2 changed files with 9 additions and 0 deletions
|
@ -1040,6 +1040,11 @@ impl PlotUi {
|
||||||
*self.last_screen_transform.bounds()
|
*self.last_screen_transform.bounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the plot bounds. Can be useful for implementing alternative plot navigation methods.
|
||||||
|
pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds) {
|
||||||
|
self.last_screen_transform.set_bounds(plot_bounds);
|
||||||
|
}
|
||||||
|
|
||||||
/// Move the plot bounds. Can be useful for implementing alternative plot navigation methods.
|
/// Move the plot bounds. Can be useful for implementing alternative plot navigation methods.
|
||||||
pub fn translate_bounds(&mut self, delta_pos: Vec2) {
|
pub fn translate_bounds(&mut self, delta_pos: Vec2) {
|
||||||
self.last_screen_transform.translate_bounds(delta_pos);
|
self.last_screen_transform.translate_bounds(delta_pos);
|
||||||
|
|
|
@ -18,6 +18,10 @@ impl PlotBounds {
|
||||||
max: [-f64::INFINITY; 2],
|
max: [-f64::INFINITY; 2],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub fn from_min_max(min: [f64; 2], max: [f64; 2]) -> Self {
|
||||||
|
Self { min, max }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn min(&self) -> [f64; 2] {
|
pub fn min(&self) -> [f64; 2] {
|
||||||
self.min
|
self.min
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue