pub struct Drawing { /* private fields */ }
Expand description
Drawing is a collection of shapes.
let mut drawing = Drawing::empty().with_canvas_size(vec2(100., 100.));
drawing.add(
Text::new("Hello World".to_owned())
.at(vec2(50., 50.))
)
.add(
Line::from(vec2(0., 0.)).to(vec2(100., 100.))
)
.add(
Circle::new()
.at(vec2(50., 50.)).with_radius(10.)
)
.add(
Image::new(ImageFormat::PNG(include_bytes!("../rustacean-flat-happy.png").to_vec()))
.at(vec2(50., 50.))
.with_size(vec2(10., 10.))
);
let other_drawing = Drawing::empty()
.with_canvas_size(vec2(210., 297.))
.add(
EmbeddedDrawing::new(drawing)
.at(vec2(100., 100.))
.with_size(vec2(10., 10.))
);
Implementations§
source§impl Drawing
impl Drawing
pub const fn with_canvas_size(self, canvas_size: Vec2) -> Self
pub const fn canvas_size(&self) -> Vec2
pub fn add<T>(&mut self, shape: T) -> &mut Selfwhere T: Into<Shape>,
pub fn into_embedded(self) -> EmbeddedDrawing
sourcepub fn shapes(&self) -> &Vec<Shape>
pub fn shapes(&self) -> &Vec<Shape>
Get access to this drawing’s shapes.
let mut drawing = Drawing::empty().with_canvas_size(vec2(100., 100.));
drawing.add(
Text::new("Hello World".to_owned())
.at(vec2(50., 50.))
)
.add(
Line::from(vec2(0., 0.)).to(vec2(100., 100.))
);
let shapes = drawing.shapes();
dbg!("{:?}", shapes);