pub struct Axes { /* private fields */ }Expand description
A plotting area: a box with ranges, a grid, axes with arrows, ticks and
labels. Derefs to Node, so it moves and fades like any node.
let axes = view.add(Axes::new().x_range(-5.0..5.0).y_range(-2.0..2.0).width(pct(80)));
let sin = axes.plot(|x| x.sin());
sin.draw_on().await;
axes.x_range().to(-10.0..10.0, 1.0).await;Implementations§
Source§impl Axes
impl Axes
Sourcepub fn new() -> AxesBuilder
pub fn new() -> AxesBuilder
Axes over -5..5 by -5..5, 80 % of the frame wide and 60 % high.
Sourcepub fn x_range(&self) -> Signal<Interval>
pub fn x_range(&self) -> Signal<Interval>
The horizontal data range. .to(0.0..20.0, 1.0) zooms the axes.
Sourcepub fn c2p(&self, x: f64, y: f64) -> Vec2
pub fn c2p(&self, x: f64, y: f64) -> Vec2
The scene point (relative to the axes) of data point (x, y), for
the ranges right now.
Sourcepub fn place(&self, node: impl Into<Node>, x: f64, y: f64)
pub fn place(&self, node: impl Into<Node>, x: f64, y: f64)
Keeps node at data point (x, y) while the ranges change. The
node becomes a child of the axes.
Sourcepub fn plot(&self, f: impl Fn(f64) -> f64 + 'static) -> Plot
pub fn plot(&self, f: impl Fn(f64) -> f64 + 'static) -> Plot
A curve of f over the visible x range. Sampled again every frame,
finer where it bends, and broken where it jumps (no line across the
gap of tan). Accent, 4 px; .stroke() and .line_width() change it.
Sourcepub fn point_on(&self, plot: &Plot, x: Signal<f64>) -> Circle
pub fn point_on(&self, plot: &Plot, x: Signal<f64>) -> Circle
A dot that sits on plot at data x x and follows it.
Sourcepub fn line_series(
&self,
points: impl IntoIterator<Item = (f64, f64)>,
) -> Series
pub fn line_series( &self, points: impl IntoIterator<Item = (f64, f64)>, ) -> Series
A polyline through data points. Each point is a signal of the series.
Sourcepub fn scatter(
&self,
points: impl IntoIterator<Item = (f64, f64)>,
) -> Vec<Circle>
pub fn scatter( &self, points: impl IntoIterator<Item = (f64, f64)>, ) -> Vec<Circle>
A dot per data point. Returns the dots in order.
Sourcepub fn bars(&self, values: impl IntoIterator<Item = f64>) -> Bars
pub fn bars(&self, values: impl IntoIterator<Item = f64>) -> Bars
A bar per value at x = 0, 1, 2, …, growing up from y = 0, with the
value printed above it. Set the x range to -0.5..n - 0.5.
Sourcepub fn matrix(&self) -> Signal<Mat2>
pub fn matrix(&self) -> Signal<Mat2>
The matrix the plane is mapped through; the identity at first.
Sourcepub fn apply_matrix(&self, m: impl Into<Mat2>, duration: f64) -> Tween<Mat2> ⓘ
pub fn apply_matrix(&self, m: impl Into<Mat2>, duration: f64) -> Tween<Mat2> ⓘ
Maps the plane through m (row by row, [[a, b], [c, d]]) over
duration seconds, after any matrix applied before. Plots, series,
vectors and placed nodes move with it, and the grid deforms. Placed
nodes keep their own shape; only their position follows.
Methods from Deref<Target = Node>§
Sourcepub fn rotation(self) -> Signal<f64>
pub fn rotation(self) -> Signal<f64>
Degrees, clockwise.
The rotation property as an animatable signal.
Sourcepub fn line_width(self) -> Signal<f64>
pub fn line_width(self) -> Signal<f64>
The line_width property as an animatable signal.
Sourcepub fn start(self) -> Signal<f64>
pub fn start(self) -> Signal<f64>
Start of the drawn part of the outline (fraction of its length).
The start property as an animatable signal.
Sourcepub fn end(self) -> Signal<f64>
pub fn end(self) -> Signal<f64>
End of the drawn part of the outline.
The end property as an animatable signal.
Sourcepub fn fill_gradient(self) -> Signal<Option<Gradient>>
pub fn fill_gradient(self) -> Signal<Option<Gradient>>
The fill_gradient property as an animatable signal.
Sourcepub fn stroke_gradient(self) -> Signal<Option<Gradient>>
pub fn stroke_gradient(self) -> Signal<Option<Gradient>>
The stroke_gradient property as an animatable signal.
Sourcepub fn dash_offset(self) -> Signal<f64>
pub fn dash_offset(self) -> Signal<f64>
The dash_offset property as an animatable signal.
Sourcepub fn shadow_color(self) -> Signal<Color>
pub fn shadow_color(self) -> Signal<Color>
The shadow_color property as an animatable signal.
Sourcepub fn shadow_blur(self) -> Signal<f64>
pub fn shadow_blur(self) -> Signal<f64>
The shadow_blur property as an animatable signal.
Sourcepub fn shadow_offset(self) -> Signal<Vec2>
pub fn shadow_offset(self) -> Signal<Vec2>
The shadow_offset property as an animatable signal.
Sourcepub fn align_self(self) -> Signal<Option<LayoutAlign>>
pub fn align_self(self) -> Signal<Option<LayoutAlign>>
The align_self property as an animatable signal.
Sourcepub fn add<B>(self, child: B) -> <B as NodeBuilder>::Handlewhere
B: NodeBuilder,
pub fn add<B>(self, child: B) -> <B as NodeBuilder>::Handlewhere
B: NodeBuilder,
Adds a child node; children are positioned relative to the parent.
The call site is stored on the node (oxframe check and oxframe inspect print it). .name("title") overrides the automatic label.
Sourcepub fn fade_in(self) -> Tween<f64> ⓘ
pub fn fade_in(self) -> Tween<f64> ⓘ
Fades the node in from transparent, over the theme’s normal duration with its enter easing.
Sourcepub fn pop_in(self) -> Tween<Vec2> ⓘ
pub fn pop_in(self) -> Tween<Vec2> ⓘ
Grows the node from nothing to its current scale with a small
overshoot (the theme’s emphasis easing, OUT_BACK by default).
Sourcepub fn draw_on(self) -> Tween<f64> ⓘ
pub fn draw_on(self) -> Tween<f64> ⓘ
Draws the outline from start to end (end from 0 to 1), as if with a
pen. Works on every shape with an outline: paths, lines, rectangles,
circles, polygons.
Sourcepub fn slide_in(self, from: Side) -> impl Future<Output = ()> + 'static
pub fn slide_in(self, from: Side) -> impl Future<Output = ()> + 'static
Slides the node into its place from SLIDE_DISTANCE pixels towards
from, fading in on the way.
Sourcepub fn next_to(self, other: impl Into<Node>, side: Side) -> Node
pub fn next_to(self, other: impl Into<Node>, side: Side) -> Node
Sits just outside other. The gap is the theme’s Md step, and the
position is recomputed every frame.
Sourcepub fn align_to(self, other: impl Into<Node>, edge: Edge) -> Node
pub fn align_to(self, other: impl Into<Node>, edge: Edge) -> Node
Lines this node’s edge up with the same edge of other.
Sourcepub fn to_edge(self, edge: Edge) -> Node
pub fn to_edge(self, edge: Edge) -> Node
Pins one edge to the safe area. The other axis is left as it is.
Sourcepub fn fade_out(self) -> Tween<f64> ⓘ
pub fn fade_out(self) -> Tween<f64> ⓘ
Fades the node out, over the theme’s normal duration with its exit easing.
Sourcepub fn effect(self, effect: EffectBuilder) -> Effect
pub fn effect(self, effect: EffectBuilder) -> Effect
Runs a shader effect on this node’s pixels, children included.
let ring = card.effect(shaders::ripple().strength(0.0));
ring.strength().to(1.0, 0.6).await;A node has one effect; a second call replaces the first. The node
must not sit inside a group with opacity below 1, a blur, a clip, a
blend, a shadow or another effect: there its pixels are not
finished, and check reports input_cycle.
Sourcepub fn absolute_position(self) -> Vec2
pub fn absolute_position(self) -> Vec2
Position of the node’s origin in scene coordinates.