Skip to main content

Axes

Struct Axes 

Source
pub struct Axes {
    pub x_range: [f64; 3],
    pub y_range: [f64; 3],
    pub to_scene: Affine,
}
Expand description

x and y axes over [min, max, step] ranges, placed in the scene by an affine map from graph coordinates. Centered on the origin when made; move it with Position or shift, and c2p follows.

The axes cross at graph (0, 0), or at the nearest end of a range that excludes 0.

Fields§

§x_range: [f64; 3]

[min, max, step] along x, in graph units.

§y_range: [f64; 3]

[min, max, step] along y, in graph units.

§to_scene: Affine

Graph coordinates to scene coordinates.

Implementations§

Source§

impl Axes

Source

pub fn new(x_range: [f64; 3], y_range: [f64; 3]) -> Self

manim’s default size: 12 units wide, 6 tall.

Source

pub fn sized( x_range: [f64; 3], y_range: [f64; 3], x_length: f64, y_length: f64, ) -> Self

Axes x_length by y_length scene units, centered on the origin.

Source

pub fn c2p(&self, x: f64, y: f64) -> Point

Graph coordinates to a scene point, manim’s c2p.

Source

pub fn p2c(&self, p: Point) -> Point

A scene point to graph coordinates, manim’s p2c.

Source

pub fn crossing(&self) -> Point

Where the axes cross, in graph coordinates.

Source

pub fn x_ticks(&self) -> Vec<f64>

Tick values along x: min, min + step, … up to max.

Source

pub fn y_ticks(&self) -> Vec<f64>

Tick values along y.

Source

pub fn shape(&self) -> VState

The axis lines and tick marks, in manim’s default style.

Source

pub fn plot(&self, f: impl Fn(f64) -> f64, x_range: Range<f64>) -> VState

Graph of y = f(x) over x_range in graph units, manim’s plot.

Source

pub fn vertical_line(&self, p: Point) -> VState

Line from scene point p straight to the x-axis, manim’s get_vertical_line (solid, not dashed).

Source

pub fn shift(self, v: Vec2) -> Self

Translates by v.

Source

pub fn move_to(self, p: Point) -> Self

Moves so the bounding-box center is at p.

Source

pub fn scale(self, factor: f64) -> Self

Scales about the bounding-box center.

Trait Implementations§

Source§

impl Clone for Axes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Axes

Source§

impl Debug for Axes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Axes

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Position for Axes

Source§

fn bbox(&self) -> Option<Rect>

The span of the axis lines, ticks excluded.

Source§

fn transform(self, a: Affine) -> Self

Applies an affine transform to the geometry.
Source§

fn next_to(self, other: &impl Position, dir: Vec2, buff: f64) -> Self

Places this buff units from other in direction dir, centered on it along the other axis, manim’s next_to (e.g. label.next_to(&dot, UP, DEFAULT_BUFF)). A diagonal dir places it off a corner.
Source§

fn align_to(self, other: &impl Position, dir: Vec2) -> Self

Lines up this edge in direction dir with the same edge of other, moving only along the axes where dir is nonzero, manim’s align_to (e.g. LEFT aligns left edges).
Source§

fn to_edge(self, dir: Vec2) -> Self

Moves against the frame edge in direction dir (e.g. UP, or UP + LEFT for a corner), leaving manim’s 0.5-unit gap.
Source§

impl StructuralPartialEq for Axes

Auto Trait Implementations§

§

impl Freeze for Axes

§

impl RefUnwindSafe for Axes

§

impl Send for Axes

§

impl Sync for Axes

§

impl Unpin for Axes

§

impl UnsafeUnpin for Axes

§

impl UnwindSafe for Axes

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.