pub enum Canvas2DCommand {
Show 15 variants
Clear {
color: Color,
},
FillRect {
x: f32,
y: f32,
width: f32,
height: f32,
color: Color,
},
StrokeRect {
x: f32,
y: f32,
width: f32,
height: f32,
color: Color,
line_width: f32,
},
FillCircle {
x: f32,
y: f32,
radius: f32,
color: Color,
},
StrokeCircle {
x: f32,
y: f32,
radius: f32,
color: Color,
line_width: f32,
},
Line {
x1: f32,
y1: f32,
x2: f32,
y2: f32,
color: Color,
line_width: f32,
},
FillText {
text: String,
x: f32,
y: f32,
font: String,
color: Color,
align: TextAlign,
baseline: TextBaseline,
},
DrawImage {
texture_id: u32,
x: f32,
y: f32,
width: f32,
height: f32,
},
DrawImageSlice {
texture_id: u32,
src_x: f32,
src_y: f32,
src_width: f32,
src_height: f32,
dst_x: f32,
dst_y: f32,
dst_width: f32,
dst_height: f32,
},
Save,
Restore,
Translate {
x: f32,
y: f32,
},
Rotate {
angle: f32,
},
Scale {
x: f32,
y: f32,
},
SetAlpha {
alpha: f32,
},
}Expand description
Canvas2D render commands that are serialized to JSON.
These commands are designed to be minimal and directly map to Canvas2D API calls. The JavaScript renderer simply iterates over commands and executes them.
Variants§
Clear
Clear the entire canvas with a color.
FillRect
Fill a rectangle.
Fields
StrokeRect
Stroke a rectangle outline.
Fields
FillCircle
Fill a circle.
StrokeCircle
Stroke a circle outline.
Fields
Line
Draw a line.
Fields
FillText
Draw text.
Fields
§
baseline: TextBaselineText baseline
DrawImage
Draw an image/sprite from a loaded texture.
Fields
DrawImageSlice
Draw a portion of an image (sprite sheet).
Fields
Save
Save the current canvas state.
Restore
Restore the previously saved canvas state.
Translate
Translate the canvas origin.
Rotate
Rotate the canvas.
Scale
Scale the canvas.
SetAlpha
Set global alpha (opacity).
Trait Implementations§
Source§impl Clone for Canvas2DCommand
impl Clone for Canvas2DCommand
Source§fn clone(&self) -> Canvas2DCommand
fn clone(&self) -> Canvas2DCommand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Canvas2DCommand
impl Debug for Canvas2DCommand
Source§impl<'de> Deserialize<'de> for Canvas2DCommand
impl<'de> Deserialize<'de> for Canvas2DCommand
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Canvas2DCommand
impl PartialEq for Canvas2DCommand
Source§impl Serialize for Canvas2DCommand
impl Serialize for Canvas2DCommand
impl StructuralPartialEq for Canvas2DCommand
Auto Trait Implementations§
impl Freeze for Canvas2DCommand
impl RefUnwindSafe for Canvas2DCommand
impl Send for Canvas2DCommand
impl Sync for Canvas2DCommand
impl Unpin for Canvas2DCommand
impl UnwindSafe for Canvas2DCommand
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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