Skip to main content

DrawCommand

Enum DrawCommand 

Source
pub enum DrawCommand {
Show 16 variants Clear { r: u8, g: u8, b: u8, a: u8, }, Rect { x: f32, y: f32, w: f32, h: f32, r: u8, g: u8, b: u8, a: u8, }, Circle { cx: f32, cy: f32, radius: f32, r: u8, g: u8, b: u8, a: u8, }, Text { x: f32, y: f32, size: f32, r: u8, g: u8, b: u8, a: u8, text: String, }, Line { x1: f32, y1: f32, x2: f32, y2: f32, r: u8, g: u8, b: u8, a: u8, thickness: f32, }, Image { x: f32, y: f32, w: f32, h: f32, image_id: usize, }, RoundedRect { x: f32, y: f32, w: f32, h: f32, radius: f32, r: u8, g: u8, b: u8, a: u8, }, Arc { cx: f32, cy: f32, radius: f32, start_angle: f32, end_angle: f32, r: u8, g: u8, b: u8, a: u8, thickness: f32, }, Bezier {
Show 13 fields x1: f32, y1: f32, cp1x: f32, cp1y: f32, cp2x: f32, cp2y: f32, x2: f32, y2: f32, r: u8, g: u8, b: u8, a: u8, thickness: f32,
}, Gradient { x: f32, y: f32, w: f32, h: f32, kind: u8, ax: f32, ay: f32, bx: f32, by: f32, stops: Vec<GradientStop>, }, Save, Restore, Transform { a: f32, b: f32, c: f32, d: f32, tx: f32, ty: f32, }, Clip { x: f32, y: f32, w: f32, h: f32, }, Opacity { alpha: f32, }, TextEx { x: f32, y: f32, size: f32, r: u8, g: u8, b: u8, a: u8, family: String, weight: u16, style: u8, align: u8, text: String, },
}
Expand description

One canvas drawing operation produced by guest api_canvas_* imports and consumed by the host renderer.

Variants§

§

Clear

Fill the entire canvas with a solid RGBA color and reset the command list (see api_canvas_clear).

Fields

§r: u8
§g: u8
§b: u8
§a: u8
§

Rect

Axis-aligned filled rectangle in canvas coordinates with RGBA fill.

Fields

§r: u8
§g: u8
§b: u8
§a: u8
§

Circle

Filled circle centered at (cx, cy) with the given radius and RGBA fill.

Fields

§cx: f32
§cy: f32
§radius: f32
§r: u8
§g: u8
§b: u8
§a: u8
§

Text

Text baseline position (x, y), font size in pixels, RGBA color, and string payload.

Fields

§size: f32
§r: u8
§g: u8
§b: u8
§a: u8
§text: String
§

Line

Line from (x1, y1) to (x2, y2) with RGBA stroke color and stroke width in pixels.

Fields

§x1: f32
§y1: f32
§x2: f32
§y2: f32
§r: u8
§g: u8
§b: u8
§a: u8
§thickness: f32
§

Image

Draw DecodedImage image_id from images into the axis-aligned rectangle (x, y, w, h).

Fields

§image_id: usize
§

RoundedRect

Filled rounded rectangle with uniform corner radius.

Fields

§radius: f32
§r: u8
§g: u8
§b: u8
§a: u8
§

Arc

Circular arc stroke from start_angle to end_angle (radians, CW from +X axis).

Fields

§cx: f32
§cy: f32
§radius: f32
§start_angle: f32
§end_angle: f32
§r: u8
§g: u8
§b: u8
§a: u8
§thickness: f32
§

Bezier

Cubic Bézier curve stroke from (x1,y1) to (x2,y2) with two control points.

Fields

§x1: f32
§y1: f32
§cp1x: f32
§cp1y: f32
§cp2x: f32
§cp2y: f32
§x2: f32
§y2: f32
§r: u8
§g: u8
§b: u8
§a: u8
§thickness: f32
§

Gradient

Linear gradient fill over an axis-aligned rectangle.

Fields

§kind: u8

0 = linear, 1 = radial.

§ax: f32

Gradient axis start (linear) or center (radial) X, relative to the rect.

§ay: f32

Gradient axis start (linear) or center (radial) Y, relative to the rect.

§bx: f32

Gradient axis end X (linear) or ignored for radial.

§by: f32

Gradient axis end Y (linear) or radius for radial.

§stops: Vec<GradientStop>

Color stops: each entry is (offset 0.0–1.0, r, g, b, a).

§

Save

Push the current transform/clip/opacity state onto the stack.

§

Restore

Pop and restore the most recently saved state.

§

Transform

Apply a 2D affine transform to subsequent draw commands (column-major: [a,b,c,d,tx,ty]).

Fields

§tx: f32
§ty: f32
§

Clip

Intersect the current clip with an axis-aligned rectangle.

Fields

§

Opacity

Set layer opacity for subsequent draw commands (0.0 transparent – 1.0 opaque).

Fields

§alpha: f32
§

TextEx

Text with explicit family, weight, style, and alignment. The baseline is at (x, y) for [TextAlign::Left]; for centre/right alignment, x is the right edge or centre respectively.

Fields

§size: f32
§r: u8
§g: u8
§b: u8
§a: u8
§family: String

CSS-style family name (e.g. "Helvetica"). Empty string falls back to the system UI font.

§weight: u16

Weight in the CSS range 100..=900. 0 means the default (400).

§style: u8

0 = normal, 1 = italic, 2 = oblique.

§align: u8

0 = left (x is left edge), 1 = centre (x is centre), 2 = right (x is right edge).

§text: String

Trait Implementations§

Source§

impl Clone for DrawCommand

Source§

fn clone(&self) -> DrawCommand

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 Debug for DrawCommand

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,