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).
Rect
Axis-aligned filled rectangle in canvas coordinates with RGBA fill.
Circle
Filled circle centered at (cx, cy) with the given radius and RGBA fill.
Text
Text baseline position (x, y), font size in pixels, RGBA color, and string payload.
Line
Line from (x1, y1) to (x2, y2) with RGBA stroke color and stroke width in pixels.
Image
Draw DecodedImage image_id from images into the axis-aligned rectangle (x, y, w, h).
RoundedRect
Filled rounded rectangle with uniform corner radius.
Arc
Circular arc stroke from start_angle to end_angle (radians, CW from +X axis).
Fields
Bezier
Cubic Bézier curve stroke from (x1,y1) to (x2,y2) with two control points.
Fields
Gradient
Linear gradient fill over an axis-aligned rectangle.
Fields
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]).
Clip
Intersect the current clip with an axis-aligned rectangle.
Opacity
Set layer opacity for subsequent draw commands (0.0 transparent – 1.0 opaque).
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.
Trait Implementations§
Source§impl Clone for DrawCommand
impl Clone for DrawCommand
Source§fn clone(&self) -> DrawCommand
fn clone(&self) -> DrawCommand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DrawCommand
impl RefUnwindSafe for DrawCommand
impl Send for DrawCommand
impl Sync for DrawCommand
impl Unpin for DrawCommand
impl UnsafeUnpin for DrawCommand
impl UnwindSafe for DrawCommand
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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