Skip to content

Commit

Permalink
Clarify how the zoom_factor argument works
Browse files Browse the repository at this point in the history
  • Loading branch information
YgorSouza committed Mar 1, 2023
1 parent 0295eb4 commit be26970
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/egui/src/widgets/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,13 +1083,19 @@ impl PlotUi {

/// Scale the plot bounds around a position in screen coordinates. Can be useful for
/// implementing alternative plot navigation methods.
/// The plot bounds are divided by `zoom_factor`, therefore:
/// `zoom_factor > 1.0` zooms in, i.e., reduces the visible range to show more detail.
/// `zoom_factor < 1.0` zooms out, i.e., increases the visible range to show more data.
pub fn zoom_bounds(&mut self, zoom_factor: Vec2, center: Pos2) {
self.last_screen_transform.zoom(zoom_factor, center);
self.bounds_modified = true.into();
}

/// Scale the plot bounds around the hovered position, if any. Can be useful for implementing
/// alternative plot navigation methods.
/// The plot bounds are divided by `zoom_factor`, therefore:
/// `zoom_factor > 1.0` zooms in, i.e., reduces the visible range to show more detail.
/// `zoom_factor < 1.0` zooms out, i.e., increases the visible range to show more data.
pub fn zoom_bounds_around_hovered(&mut self, zoom_factor: Vec2) {
if let Some(hover_pos) = self.response.hover_pos() {
self.zoom_bounds(zoom_factor, hover_pos);
Expand Down

0 comments on commit be26970

Please sign in to comment.