pub enum DrawCommand {
Path {
points: Vec<Point>,
closed: bool,
style: StrokeStyle,
},
Fill {
path: PathRef,
color: Color,
rule: FillRule,
},
Rect {
bounds: Rect,
radius: CornerRadius,
style: BoxStyle,
},
Circle {
center: Point,
radius: f32,
style: BoxStyle,
},
Arc {
center: Point,
radius: f32,
start_angle: f32,
end_angle: f32,
color: Color,
},
Text {
content: String,
position: Point,
style: TextStyle,
},
Image {
tensor: TensorRef,
bounds: Rect,
sampling: Sampling,
},
Group {
children: Vec<Self>,
transform: Transform2D,
},
Clip {
bounds: Rect,
child: Box<Self>,
},
Opacity {
alpha: f32,
child: Box<Self>,
},
}Expand description
Drawing primitive - all rendering reduces to these.
Variants§
Path
Draw a path (polyline or polygon)
Fields
§
style: StrokeStyleStroke style
Fill
Fill a path
Rect
Draw a rectangle
Circle
Draw a circle
Arc
Draw an arc (pie slice)
Fields
Text
Draw text
Image
Draw an image from tensor
Fields
Group
Group of commands with transform
Clip
Clip to bounds
Opacity
Apply opacity
Implementations§
Source§impl DrawCommand
impl DrawCommand
Sourcepub const fn filled_rect(bounds: Rect, color: Color) -> Self
pub const fn filled_rect(bounds: Rect, color: Color) -> Self
Create a filled rectangle.
Sourcepub const fn rounded_rect(bounds: Rect, radius: f32, color: Color) -> Self
pub const fn rounded_rect(bounds: Rect, radius: f32, color: Color) -> Self
Create a rounded rectangle.
Sourcepub const fn stroked_rect(bounds: Rect, stroke: StrokeStyle) -> Self
pub const fn stroked_rect(bounds: Rect, stroke: StrokeStyle) -> Self
Create a stroked rectangle.
Sourcepub const fn filled_circle(center: Point, radius: f32, color: Color) -> Self
pub const fn filled_circle(center: Point, radius: f32, color: Color) -> Self
Create a filled circle.
Sourcepub fn line(from: Point, to: Point, style: StrokeStyle) -> Self
pub fn line(from: Point, to: Point, style: StrokeStyle) -> Self
Create a line between two points.
Sourcepub fn with_transform(self, transform: Transform2D) -> Self
pub fn with_transform(self, transform: Transform2D) -> Self
Wrap in a group with transform.
Sourcepub fn with_opacity(self, alpha: f32) -> Self
pub fn with_opacity(self, alpha: f32) -> Self
Wrap with opacity.
Trait Implementations§
Source§impl Clone for DrawCommand
impl Clone for DrawCommand
Source§fn clone(&self) -> DrawCommand
fn clone(&self) -> DrawCommand
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 DrawCommand
impl Debug for DrawCommand
Source§impl<'de> Deserialize<'de> for DrawCommand
impl<'de> Deserialize<'de> for DrawCommand
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 DrawCommand
impl PartialEq for DrawCommand
Source§impl Serialize for DrawCommand
impl Serialize for DrawCommand
impl StructuralPartialEq for DrawCommand
Auto Trait Implementations§
impl Freeze for DrawCommand
impl RefUnwindSafe for DrawCommand
impl Send for DrawCommand
impl Sync for DrawCommand
impl Unpin for DrawCommand
impl UnwindSafe for DrawCommand
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