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, x_centered: bool, y_centered: bool, ) -> PlotTransform
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: Vec2)
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 moreSource§impl Debug for PlotTransform
impl Debug for PlotTransform
impl Copy for PlotTransform
Auto Trait Implementations§
impl Freeze for PlotTransform
impl RefUnwindSafe for PlotTransform
impl Send for PlotTransform
impl Sync for PlotTransform
impl Unpin for PlotTransform
impl UnwindSafe for PlotTransform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more