Skip to main content

MathBuilder

Struct MathBuilder 

Source
pub struct MathBuilder { /* private fields */ }
Expand description

Builder for a Math node: Math::new("a^2 + b^2 = c^2").size(64.0).

Implementations§

Source§

impl MathBuilder

Source

pub fn size(self, v: f64) -> Self

Font size in pixels, as for Txt. Default: the same as Txt.

Source

pub fn color(self, v: impl IntoPaint) -> Self

Color of every glyph and rule. Default: the theme’s text color.

Source

pub fn display(self) -> Self

Sets the formula on its own line, as $ … $ in Typst: sums and integrals get their limits above and below, fractions are full size. The default is inline math, as in running text.

Trait Implementations§

Source§

impl Debug for MathBuilder

Source§

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

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

impl NodeBuilder for MathBuilder

Source§

type Handle = Math

Handle returned by Node::add.
Source§

fn name(self, v: impl Into<String>) -> Self

Name shown in the editor and in oxframe check / oxframe inspect. Without it, the node is labeled by the add call site (src/main.rs:42).
Source§

fn x(self, v: f64) -> Self

Horizontal position; 0 is the parent’s center, positive is right.
Source§

fn y(self, v: f64) -> Self

Vertical position; 0 is the parent’s center, positive is down.
Source§

fn position(self, v: impl Into<Vec2>) -> Self

Sets x and y together, e.g. .position((100.0, -50.0)).
Source§

fn rotation(self, v: f64) -> Self

Degrees, clockwise.
Source§

fn scale(self, v: f64) -> Self

Uniform scale; 1 is the natural size.
Source§

fn scale_xy(self, v: impl Into<Vec2>) -> Self

Separate horizontal and vertical scale.
Source§

fn opacity(self, v: f64) -> Self

Opacity of the node and its children, 0 (invisible) to 1.
Source§

fn fill(self, v: impl IntoPaint) -> Self

Fill color: a Color or a theme role such as Accent. Default: transparent, except text, which uses the theme’s text color.
Source§

fn stroke(self, v: impl IntoPaint) -> Self

Outline color; also set line_width. A theme role works the same as a color. Default: transparent.
Source§

fn line_width(self, v: f64) -> Self

Outline width in pixels. Default: 0 (no outline).
Source§

fn start(self, v: f64) -> Self

Start of the drawn part of the outline, fraction of its length.
Source§

fn end(self, v: f64) -> Self

End of the drawn part of the outline; animate 0 → 1 to draw it on.
Source§

fn fill_gradient(self, g: Gradient) -> Self

Gradient fill (local coordinates, origin at the node center); overrides fill.
Source§

fn stroke_gradient(self, g: Gradient) -> Self

Gradient outline; overrides stroke.
Source§

fn dash(self, pattern: impl Into<Vec<f64>>) -> Self

Dash pattern: on, off, on, … lengths. Animate dash_offset for marching ants.
Source§

fn dash_offset(self, v: f64) -> Self

Shifts the dash pattern along the outline.
Source§

fn line_cap(self, v: LineCap) -> Self

Shape of outline ends. Default: round.
Source§

fn line_join(self, v: LineJoin) -> Self

Shape of outline corners. Default: round.
Source§

fn blur(self, v: f64) -> Self

Gaussian blur of the node and its children (standard deviation, in the node’s units).
Source§

fn shadow( self, color: impl IntoPaint, blur: f64, offset: impl Into<Vec2>, ) -> Self

Drop shadow under the node and its children.
Source§

fn elevation(self, step: Step) -> Self

The theme’s shadow for this step (Xs and Sm are the small one, Xl the large).
Source§

fn glow(self, color: impl IntoPaint, blur: f64) -> Self

A shadow without offset.
Source§

fn clip(self, v: bool) -> Self

Clip children to this node’s outline (or box).
Source§

fn blend(self, v: BlendMode) -> Self

How the node is composited onto what is below it.
Source§

fn z_index(self, v: f64) -> Self

Paint order among siblings; higher is on top.
Source§

fn anchor(self, v: impl Into<Vec2>) -> Self

Pivot and placement point: (-1, -1) top-left … (1, 1) bottom-right.
Source§

fn grow(self, v: f64) -> Self

Inside a Layout: share of the free space this node takes.
Source§

fn shrink(self, v: f64) -> Self

Inside a Layout: how much this node gives up when space is short.
Source§

fn basis(self, v: f64) -> Self

Inside a Layout: main-axis size before growing/shrinking.
Source§

fn margin(self, v: impl Len) -> Self

Inside a Layout: space around this node, in pixels or a theme step (.margin(Md)).
Source§

fn align_self(self, v: LayoutAlign) -> Self

Inside a Layout: overrides the layout’s cross-axis alignment.
Source§

fn next_to(self, other: impl Into<Node>, side: Side) -> Self

Sits just outside other, on side. The gap is the theme’s Md step. Recomputed every frame, so this node follows other.
Source§

fn align_to(self, other: impl Into<Node>, edge: Edge) -> Self

Lines this node’s edge up with the same edge of other.
Source§

fn to_edge(self, edge: Edge) -> Self

Pins one edge to the safe area (not the raw frame edge). The other axis stays at x or y.
Source§

fn center_in(self, other: impl Into<Node>) -> Self

Same center as other. Pass the view to center in the frame.
Source§

fn child<C: NodeBuilder>(self, child: C) -> Self

Adds a child created together with this node. Use Node::add when you need the child’s handle.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.