Struct iced::widget::canvas::Frame

source ·
pub struct Frame { /* private fields */ }
Available on crate feature canvas only.
Expand description

The frame of a Canvas.

Implementations§

source§

impl Frame

source

pub fn new(size: Size<f32>) -> Frame

Creates a new empty Frame with the given dimensions.

The default coordinate system of a Frame has its origin at the top-left corner of its bounds.

source

pub fn width(&self) -> f32

Returns the width of the Frame.

source

pub fn height(&self) -> f32

Returns the height of the Frame.

source

pub fn size(&self) -> Size<f32>

Returns the dimensions of the Frame.

source

pub fn center(&self) -> Point

Returns the coordinate of the center of the Frame.

source

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.

source

pub fn fill_rectangle( &mut self, top_left: Point, size: Size<f32>, 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.

source

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.

source

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: 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.

source

pub fn with_save(&mut self, f: impl FnOnce(&mut Frame))

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.

source

pub fn with_clip(&mut self, region: Rectangle<f32>, f: impl FnOnce(&mut Frame))

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.

source

pub fn translate(&mut self, translation: Vector<f32>)

Applies a translation to the current transform of the Frame.

source

pub fn rotate(&mut self, angle: f32)

Applies a rotation in radians to the current transform of the Frame.

source

pub fn scale(&mut self, scale: f32)

Applies a scaling to the current transform of the Frame.

source

pub fn into_geometry(self) -> Geometry

Produces the Geometry representing everything drawn on the Frame.

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§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> IntoColor<U> for Twhere U: FromColor<T>,

source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,

source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,

source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> MaybeSend for Twhere T: Send,