pub type Frame<Renderer = Renderer> = Frame<Renderer>;
canvas
only.Expand description
The frame supported by a renderer.
Aliased Type§
struct Frame<Renderer = Renderer> { /* private fields */ }
Implementations
§impl<Renderer> Frame<Renderer>where
Renderer: Renderer,
impl<Renderer> Frame<Renderer>where
Renderer: Renderer,
pub fn new(renderer: &Renderer, size: Size) -> Frame<Renderer>
pub fn new(renderer: &Renderer, size: Size) -> Frame<Renderer>
Creates a new [Frame
] with the given dimensions.
pub fn size(&self) -> Size
pub fn size(&self) -> Size
Returns the dimensions of the [Frame
].
pub fn center(&self) -> Point
pub fn center(&self) -> Point
Returns the coordinate of the center of the [Frame
].
pub fn fill(&mut self, path: &Path, fill: impl Into<Fill>)
pub fn fill(&mut self, path: &Path, fill: impl Into<Fill>)
Draws the given Path
on the [Frame
] by filling it with the
provided style.
pub fn fill_rectangle(
&mut self,
top_left: Point,
size: Size,
fill: impl Into<Fill>,
)
pub fn fill_rectangle( &mut self, top_left: Point, size: Size, fill: impl Into<Fill>, )
Draws an axis-aligned rectangle given its top-left corner coordinate and
its Size
on the [Frame
] by filling it with the provided style.
pub fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>)
pub fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>)
Draws the stroke of the given Path
on the [Frame
] with the
provided style.
pub fn stroke_rectangle<'a>(
&mut self,
top_left: Point,
size: Size,
stroke: impl Into<Stroke<'a>>,
)
pub fn stroke_rectangle<'a>( &mut self, top_left: Point, size: Size, stroke: impl Into<Stroke<'a>>, )
Draws the stroke of an axis-aligned rectangle with the provided style
given its top-left corner coordinate and its Size
on the [Frame
] .
pub fn fill_text(&mut self, text: impl Into<Text>)
pub fn fill_text(&mut self, text: impl Into<Text>)
Draws the characters of the given Text
on the [Frame
], filling
them with the given color.
Warning: 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.
pub fn draw_image(&mut self, bounds: Rectangle, image: impl Into<Image>)
pub fn draw_image(&mut self, bounds: Rectangle, image: impl Into<Image>)
Draws the given Image
on the [Frame
] inside the given bounds.
pub fn draw_svg(&mut self, bounds: Rectangle, svg: impl Into<Svg>)
pub fn draw_svg(&mut self, bounds: Rectangle, svg: impl Into<Svg>)
Draws the given [Svg
] on the [Frame
] inside the given bounds.
pub fn with_save<R>(&mut self, f: impl FnOnce(&mut Frame<Renderer>) -> R) -> R
pub fn with_save<R>(&mut self, f: impl FnOnce(&mut Frame<Renderer>) -> R) -> R
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.
pub fn push_transform(&mut self)
pub fn push_transform(&mut self)
Pushes the current transform in the transform stack.
pub fn pop_transform(&mut self)
pub fn pop_transform(&mut self)
Pops a transform from the transform stack and sets it as the current transform.
pub fn with_clip<R>(
&mut self,
region: Rectangle,
f: impl FnOnce(&mut Frame<Renderer>) -> R,
) -> R
pub fn with_clip<R>( &mut self, region: Rectangle, f: impl FnOnce(&mut Frame<Renderer>) -> R, ) -> R
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.
pub fn translate(&mut self, translation: Vector)
pub fn translate(&mut self, translation: Vector)
Applies a translation to the current transform of the [Frame
].
pub fn rotate(&mut self, angle: impl Into<Radians>)
pub fn rotate(&mut self, angle: impl Into<Radians>)
Applies a rotation in radians to the current transform of the [Frame
].
pub fn scale(&mut self, scale: impl Into<f32>)
pub fn scale(&mut self, scale: impl Into<f32>)
Applies a uniform scaling to the current transform of the [Frame
].
pub fn scale_nonuniform(&mut self, scale: impl Into<Vector>)
pub fn scale_nonuniform(&mut self, scale: impl Into<Vector>)
Applies a non-uniform scaling to the current transform of the [Frame
].
pub fn into_geometry(self) -> <Renderer as Renderer>::Geometry
pub fn into_geometry(self) -> <Renderer as Renderer>::Geometry
Turns the [Frame
] into its underlying geometry.