pub struct Frame { /* private fields */ }
pure
only.Expand description
The frame of a Canvas
.
Implementations
sourceimpl Frame
impl Frame
sourcepub fn width(&self) -> f32
Available on crate feature canvas
only.
pub fn width(&self) -> f32
canvas
only.Returns the width of the Frame
.
sourcepub fn height(&self) -> f32
Available on crate feature canvas
only.
pub fn height(&self) -> f32
canvas
only.Returns the height of the Frame
.
sourcepub fn size(&self) -> Size<f32>
Available on crate feature canvas
only.
pub fn size(&self) -> Size<f32>
canvas
only.Returns the dimensions of the Frame
.
sourcepub fn center(&self) -> Point
Available on crate feature canvas
only.
pub fn center(&self) -> Point
canvas
only.Returns the coordinate of the center of the Frame
.
sourcepub fn fill(&mut self, path: &Path, fill: impl Into<Fill>)
Available on crate feature canvas
only.
pub fn fill(&mut self, path: &Path, fill: impl Into<Fill>)
canvas
only.sourcepub fn fill_rectangle(
&mut self,
top_left: Point,
size: Size<f32>,
fill: impl Into<Fill>
)
Available on crate feature canvas
only.
pub fn fill_rectangle(
&mut self,
top_left: Point,
size: Size<f32>,
fill: impl Into<Fill>
)
canvas
only.Draws an axis-aligned rectangle given its top-left corner coordinate and
its Size
on the Frame
by filling it with the provided style.
sourcepub fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>)
Available on crate feature canvas
only.
pub fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>)
canvas
only.sourcepub fn fill_text(&mut self, text: impl Into<Text>)
Available on crate feature canvas
only.
pub fn fill_text(&mut self, text: impl Into<Text>)
canvas
only.Draws the characters of the given Text
on the Frame
, filling
them with the given color.
Warning: Text currently does not work well with rotations and scale transforms! The position will be correctly transformed, but the resulting glyphs will not be rotated or scaled properly.
Additionally, all text will be rendered on top of all the layers of
a Canvas
. Therefore, it is currently only meant to be used for
overlays, which is the most common use case.
Support for vectorial text is planned, and should address all these limitations.
sourcepub fn with_save(&mut self, f: impl FnOnce(&mut Frame))
Available on crate feature canvas
only.
pub fn with_save(&mut self, f: impl FnOnce(&mut Frame))
canvas
only.Stores the current transform of the Frame
and executes the given
drawing operations, restoring the transform afterwards.
This method is useful to compose transforms and perform drawing operations in different coordinate systems.
sourcepub fn with_clip(&mut self, region: Rectangle<f32>, f: impl FnOnce(&mut Frame))
Available on crate feature canvas
only.
pub fn with_clip(&mut self, region: Rectangle<f32>, f: impl FnOnce(&mut Frame))
canvas
only.Executes the given drawing operations within a Rectangle
region,
clipping any geometry that overflows its bounds. Any transformations
performed are local to the provided closure.
This method is useful to perform drawing operations that need to be clipped.
sourcepub fn translate(&mut self, translation: Vector<f32>)
Available on crate feature canvas
only.
pub fn translate(&mut self, translation: Vector<f32>)
canvas
only.Applies a translation to the current transform of the Frame
.
sourcepub fn rotate(&mut self, angle: f32)
Available on crate feature canvas
only.
pub fn rotate(&mut self, angle: f32)
canvas
only.Applies a rotation to the current transform of the Frame
.
sourcepub fn scale(&mut self, scale: f32)
Available on crate feature canvas
only.
pub fn scale(&mut self, scale: f32)
canvas
only.Applies a scaling to the current transform of the Frame
.
sourcepub fn into_geometry(self) -> Geometry
Available on crate feature canvas
only.
pub fn into_geometry(self) -> Geometry
canvas
only.Auto Trait Implementations
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more