pub struct PlotTransform { /* private fields */ }Expand description
Contains the screen rectangle and the plot bounds and provides methods to transform between them.
Implementations§
Source§impl PlotTransform
impl PlotTransform
pub fn new(frame: Rect, bounds: PlotBounds, center_axis: Vec2b) -> Self
Sourcepub fn bounds(&self) -> &PlotBounds
pub fn bounds(&self) -> &PlotBounds
Plot-space bounds.
pub fn set_bounds(&mut self, bounds: PlotBounds)
pub fn translate_bounds(&mut self, delta_pos: (f64, f64))
Sourcepub fn zoom(&mut self, zoom_factor: Vec2, center: Pos2)
pub fn zoom(&mut self, zoom_factor: Vec2, center: Pos2)
Zoom by a relative factor with the given screen position as center.
pub fn position_from_point_x(&self, value: f64) -> f32
pub fn position_from_point_y(&self, value: f64) -> f32
Sourcepub fn position_from_point(&self, value: &PlotPoint) -> Pos2
pub fn position_from_point(&self, value: &PlotPoint) -> Pos2
Screen/ui position from point on plot.
Sourcepub fn value_from_position(&self, pos: Pos2) -> PlotPoint
pub fn value_from_position(&self, pos: Pos2) -> PlotPoint
Plot point from screen/ui position.
Sourcepub fn rect_from_values(&self, value1: &PlotPoint, value2: &PlotPoint) -> Rect
pub fn rect_from_values(&self, value1: &PlotPoint, value2: &PlotPoint) -> Rect
Transform a rectangle of plot values to a screen-coordinate rectangle.
This typically means that the rect is mirrored vertically (top becomes bottom and vice versa), since the plot’s coordinate system has +Y up, while egui has +Y down.
Sourcepub fn dpos_dvalue_x(&self) -> f64
pub fn dpos_dvalue_x(&self) -> f64
delta position / delta value = how many ui points per step in the X axis in “plot space”
Sourcepub fn dpos_dvalue_y(&self) -> f64
pub fn dpos_dvalue_y(&self) -> f64
delta position / delta value = how many ui points per step in the Y axis in “plot space”
Sourcepub fn dpos_dvalue(&self) -> [f64; 2]
pub fn dpos_dvalue(&self) -> [f64; 2]
delta position / delta value = how many ui points per step in “plot space”
Sourcepub fn dvalue_dpos(&self) -> [f64; 2]
pub fn dvalue_dpos(&self) -> [f64; 2]
delta value / delta position = how much ground do we cover in “plot space” per ui point?
Trait Implementations§
Source§impl Clone for PlotTransform
impl Clone for PlotTransform
Source§fn clone(&self) -> PlotTransform
fn clone(&self) -> PlotTransform
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more