Skip to main content

ShapePieceBuilder

Trait ShapePieceBuilder 

Source
pub trait ShapePieceBuilder: Sized {
    // Required methods
    fn fill<M>(self, p: impl IntoReactive<Color, M>) -> Self;
    fn fill_linear<M>(self, g: impl IntoReactive<LinearGradient, M>) -> Self;
    fn fill_radial<M>(self, g: impl IntoReactive<RadialGradient, M>) -> Self;
    fn stroke<M1, M2>(
        self,
        color: impl IntoReactive<Color, M1>,
        width: impl IntoReactive<f64, M2>,
    ) -> Self;
    fn inset<M>(self, v: impl IntoReactive<f64, M>) -> Self;
    fn rotate<M>(self, deg: impl IntoReactive<f64, M>) -> Self;
    fn scale<M>(self, s: impl IntoReactive<f64, M>) -> Self;
    fn offset<M1, M2>(
        self,
        x: impl IntoReactive<f64, M1>,
        y: impl IntoReactive<f64, M2>,
    ) -> Self;
    fn at(self, fx: f64, fy: f64, fw: f64, fh: f64) -> Self;
    fn on_tap(self, f: impl Fn() + 'static) -> Self;
    fn on_drag(self, f: impl Fn(Drag) + 'static) -> Self;
}
Expand description

Builder methods of ShapePiece, reachable through a Decorated (docs/api-style.md “Typed builders and erasure”): generic modifiers and typed ones chain in any order.

Required Methods§

Source

fn fill<M>(self, p: impl IntoReactive<Color, M>) -> Self

Source

fn fill_linear<M>(self, g: impl IntoReactive<LinearGradient, M>) -> Self

Fill with a LinearGradient (unit points resolve against the shape’s bounds). Takes precedence over Self::fill when both are set; reactive like every other property: rectangle().fill_linear(move || sky_gradient(state.get())).

Source

fn fill_radial<M>(self, g: impl IntoReactive<RadialGradient, M>) -> Self

Fill with a RadialGradient (center + radius in the unit space of the shape’s bounds, stretching elliptically in non-square bounds). Precedence: radial over linear over solid.

Source

fn stroke<M1, M2>( self, color: impl IntoReactive<Color, M1>, width: impl IntoReactive<f64, M2>, ) -> Self

Source

fn inset<M>(self, v: impl IntoReactive<f64, M>) -> Self

Uniform inset applied before resolving geometry (keeps strokes inside the frame).

Source

fn rotate<M>(self, deg: impl IntoReactive<f64, M>) -> Self

Rotate the drawn shape about its center, in degrees.

Source

fn scale<M>(self, s: impl IntoReactive<f64, M>) -> Self

Scale the drawn shape about its center (uniform).

Source

fn offset<M1, M2>( self, x: impl IntoReactive<f64, M1>, y: impl IntoReactive<f64, M2>, ) -> Self

Translate the drawn shape within its frame.

Source

fn at(self, fx: f64, fy: f64, fw: f64, fh: f64) -> Self

Resolve this shape inside the fractional sub-rect (fx, fy, fw, fh) of its bounds (unit-space, applied before Self::inset). The workhorse for composing glyphs in a shape_group, mirroring hand-drawn Rect::new(ox + fx * s, oy + fy * s, …) canvas code.

Source

fn on_tap(self, f: impl Fn() + 'static) -> Self

Fire when the shape is tapped (path-precise: the tap is tested against the resolved path).

Source

fn on_drag(self, f: impl Fn(Drag) + 'static) -> Self

Fire on each phase of a drag over the shape.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Day API ↩ Guides· daybrite.dev