pub struct DrawContext { /* private fields */ }Expand description
Immediate-mode drawing context used by canvas(size, draw).
Implementations§
Source§impl DrawContext
impl DrawContext
Sourcepub fn bounds(&self) -> Bounds<Pixels>
pub fn bounds(&self) -> Bounds<Pixels>
Returns the canvas-local bounds for the current draw pass.
Sourcepub fn fill_path(&mut self, path: &Path<Pixels>, fill: impl Into<Background>)
pub fn fill_path(&mut self, path: &Path<Pixels>, fill: impl Into<Background>)
Fill an existing path with the given background.
Sourcepub fn stroke_path(&mut self, path: &Path<Pixels>, stroke: Stroke)
pub fn stroke_path(&mut self, path: &Path<Pixels>, stroke: Stroke)
Stroke a path using the retained source outline stored on the path.
Sourcepub fn stroke_line(
&mut self,
from: Point<Pixels>,
to: Point<Pixels>,
stroke: Stroke,
)
pub fn stroke_line( &mut self, from: Point<Pixels>, to: Point<Pixels>, stroke: Stroke, )
Stroke a straight line segment between two points.
Sourcepub fn fill_rect(&mut self, bounds: Bounds<Pixels>, fill: impl Into<Background>)
pub fn fill_rect(&mut self, bounds: Bounds<Pixels>, fill: impl Into<Background>)
Fill an axis-aligned rectangle.
Sourcepub fn fill_rounded_rect(
&mut self,
bounds: Bounds<Pixels>,
radii: impl Into<Corners<Pixels>>,
fill: impl Into<Background>,
)
pub fn fill_rounded_rect( &mut self, bounds: Bounds<Pixels>, radii: impl Into<Corners<Pixels>>, fill: impl Into<Background>, )
Fill a rounded rectangle.
Sourcepub fn fill_circle(
&mut self,
center: Point<Pixels>,
radius: Pixels,
fill: impl Into<Background>,
)
pub fn fill_circle( &mut self, center: Point<Pixels>, radius: Pixels, fill: impl Into<Background>, )
Fill a circle.
Sourcepub fn stroke_circle(
&mut self,
center: Point<Pixels>,
radius: Pixels,
stroke: Stroke,
)
pub fn stroke_circle( &mut self, center: Point<Pixels>, radius: Pixels, stroke: Stroke, )
Stroke a circle.
Sourcepub fn with_transform<R>(
&mut self,
matrix: TransformationMatrix,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_transform<R>( &mut self, matrix: TransformationMatrix, f: impl FnOnce(&mut Self) -> R, ) -> R
Apply an affine transform to commands issued within the callback.
Sourcepub fn with_opacity<R>(
&mut self,
opacity: f32,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_opacity<R>( &mut self, opacity: f32, f: impl FnOnce(&mut Self) -> R, ) -> R
Multiply the current drawing opacity for commands issued within the callback.
Sourcepub fn with_clip<R>(
&mut self,
bounds: Bounds<Pixels>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_clip<R>( &mut self, bounds: Bounds<Pixels>, f: impl FnOnce(&mut Self) -> R, ) -> R
Restrict drawing to an additional clip rectangle.
Auto Trait Implementations§
impl Freeze for DrawContext
impl RefUnwindSafe for DrawContext
impl Send for DrawContext
impl Sync for DrawContext
impl Unpin for DrawContext
impl UnsafeUnpin for DrawContext
impl UnwindSafe for DrawContext
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more