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
impl PlotUi
pub fn ctx(&self) -> &Context
sourcepub fn plot_bounds(&self) -> PlotBounds
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.
sourcepub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds)
pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds)
Set the plot bounds. Can be useful for implementing alternative plot navigation methods.
sourcepub fn translate_bounds(&mut self, delta_pos: Vec2)
pub fn translate_bounds(&mut self, delta_pos: Vec2)
Move the plot bounds. Can be useful for implementing alternative plot navigation methods.
sourcepub fn plot_hovered(&self) -> bool
👎Deprecated: Use plot_ui.response().hovered()
pub fn plot_hovered(&self) -> bool
Returns true
if the plot area is currently hovered.
sourcepub fn plot_clicked(&self) -> bool
👎Deprecated: Use plot_ui.response().clicked()
pub fn plot_clicked(&self) -> bool
Returns true
if the plot was clicked by the primary button.
sourcepub fn plot_secondary_clicked(&self) -> bool
👎Deprecated: Use plot_ui.response().secondary_clicked()
pub fn plot_secondary_clicked(&self) -> bool
Returns true
if the plot was clicked by the secondary button.
sourcepub fn pointer_coordinate(&self) -> Option<PlotPoint>
pub fn pointer_coordinate(&self) -> Option<PlotPoint>
The pointer position in plot coordinates. Independent of whether the pointer is in the plot area.
sourcepub fn pointer_coordinate_drag_delta(&self) -> Vec2
pub fn pointer_coordinate_drag_delta(&self) -> Vec2
The pointer drag delta in plot coordinates.
sourcepub fn transform(&self) -> &PlotTransform
pub fn transform(&self) -> &PlotTransform
Read the transform netween plot coordinates and screen coordinates.
sourcepub fn screen_from_plot(&self, position: PlotPoint) -> Pos2
pub fn screen_from_plot(&self, position: PlotPoint) -> Pos2
Transform the plot coordinates to screen coordinates.
sourcepub fn plot_from_screen(&self, position: Pos2) -> PlotPoint
pub fn plot_from_screen(&self, position: Pos2) -> PlotPoint
Transform the screen coordinates to plot coordinates.
sourcepub fn stacked_line(&mut self, line: StackedLine)
pub fn stacked_line(&mut self, line: StackedLine)
Add a stacked data line.