Struct maelstrom_plot::PlotUi

source ·
pub struct PlotUi { /* private fields */ }
Expand description

Provides methods to interact with a plot while building it. It is the single argument of the closure provided to Plot::show. See Plot for an example of how to use it.

Implementations§

source§

impl PlotUi

source

pub fn ctx(&self) -> &Context

source

pub fn plot_bounds(&self) -> PlotBounds

The plot bounds as they were in the last frame. If called on the first frame and the bounds were not further specified in the plot builder, this will return bounds centered on the origin. The bounds do not change until the plot is drawn.

source

pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds)

Set the plot bounds. Can be useful for implementing alternative plot navigation methods.

source

pub fn translate_bounds(&mut self, delta_pos: Vec2)

Move the plot bounds. Can be useful for implementing alternative plot navigation methods.

source

pub fn response(&self) -> &Response

Can be used to check if the plot was hovered or clicked.

source

pub fn plot_hovered(&self) -> bool

👎Deprecated: Use plot_ui.response().hovered()

Returns true if the plot area is currently hovered.

source

pub fn plot_clicked(&self) -> bool

👎Deprecated: Use plot_ui.response().clicked()

Returns true if the plot was clicked by the primary button.

source

pub fn plot_secondary_clicked(&self) -> bool

👎Deprecated: Use plot_ui.response().secondary_clicked()

Returns true if the plot was clicked by the secondary button.

source

pub fn pointer_coordinate(&self) -> Option<PlotPoint>

The pointer position in plot coordinates. Independent of whether the pointer is in the plot area.

source

pub fn pointer_coordinate_drag_delta(&self) -> Vec2

The pointer drag delta in plot coordinates.

source

pub fn transform(&self) -> &PlotTransform

Read the transform netween plot coordinates and screen coordinates.

source

pub fn screen_from_plot(&self, position: PlotPoint) -> Pos2

Transform the plot coordinates to screen coordinates.

source

pub fn plot_from_screen(&self, position: Pos2) -> PlotPoint

Transform the screen coordinates to plot coordinates.

source

pub fn line(&mut self, line: Line)

Add a data line.

source

pub fn stacked_line(&mut self, line: StackedLine)

Add a stacked data line.

source

pub fn text(&mut self, text: Text)

Add a text.

source

pub fn points(&mut self, points: Points)

Add data points.

Auto Trait Implementations§

§

impl Freeze for PlotUi

§

impl !RefUnwindSafe for PlotUi

§

impl !Send for PlotUi

§

impl !Sync for PlotUi

§

impl Unpin for PlotUi

§

impl !UnwindSafe for PlotUi

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.