pub struct Canvas;Expand description
Immediate-mode canvas facade that wraps the low-level drawing functions.
All methods paint immediately (no retained scene graph). Create one per
frame or per start_app call and issue draw commands through it.
Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn fill_rounded_rect(&self, rect: Rect, radius: f32, color: Color)
pub fn fill_rounded_rect(&self, rect: Rect, radius: f32, color: Color)
Draw a filled rounded rectangle with uniform corner radius.
Sourcepub fn fill_circle(&self, center: Point2D, radius: f32, color: Color)
pub fn fill_circle(&self, center: Point2D, radius: f32, color: Color)
Draw a filled circle.
Sourcepub fn arc(
&self,
center: Point2D,
radius: f32,
start_angle: f32,
end_angle: f32,
thickness: f32,
color: Color,
)
pub fn arc( &self, center: Point2D, radius: f32, start_angle: f32, end_angle: f32, thickness: f32, color: Color, )
Draw a circular arc stroke from start_angle to end_angle (radians).
Sourcepub fn bezier(
&self,
from: Point2D,
ctrl1: Point2D,
ctrl2: Point2D,
to: Point2D,
thickness: f32,
color: Color,
)
pub fn bezier( &self, from: Point2D, ctrl1: Point2D, ctrl2: Point2D, to: Point2D, thickness: f32, color: Color, )
Draw a cubic Bézier curve stroke.
Sourcepub fn line(&self, from: Point2D, to: Point2D, thickness: f32, color: Color)
pub fn line(&self, from: Point2D, to: Point2D, thickness: f32, color: Color)
Draw a line between two points.
Sourcepub fn image(&self, rect: Rect, data: &[u8])
pub fn image(&self, rect: Rect, data: &[u8])
Draw an image from encoded bytes (PNG, JPEG, GIF, WebP).
Sourcepub fn linear_gradient(&self, rect: Rect, stops: &[GradientStop])
pub fn linear_gradient(&self, rect: Rect, stops: &[GradientStop])
Fill a rectangle with a linear gradient.
Sourcepub fn radial_gradient(&self, rect: Rect, stops: &[GradientStop])
pub fn radial_gradient(&self, rect: Rect, stops: &[GradientStop])
Fill a rectangle with a radial gradient.
Sourcepub fn transform(&self, a: f32, b: f32, c: f32, d: f32, tx: f32, ty: f32)
pub fn transform(&self, a: f32, b: f32, c: f32, d: f32, tx: f32, ty: f32)
Apply a full 2D affine transform.
Sourcepub fn set_opacity(&self, alpha: f32)
pub fn set_opacity(&self, alpha: f32)
Set layer opacity (0.0–1.0) for subsequent draw commands.
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Get the canvas dimensions in pixels.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Canvas
impl RefUnwindSafe for Canvas
impl Send for Canvas
impl Sync for Canvas
impl Unpin for Canvas
impl UnsafeUnpin for Canvas
impl UnwindSafe for Canvas
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