Struct kas::draw::DrawIface [−][src]
pub struct DrawIface<'a, DS> where
DS: DrawSharedImpl, { /* fields omitted */ }
Expand description
Draw interface object
Draw
and extension traits such as DrawRounded
provide draw
functionality over this object.
This type is used to present a unified mid-level draw interface, as
available from DrawHandle::draw_device
. A concrete DrawIface
object may be
obtained via downcast, e.g.:
impl CircleWidget {
fn draw(&self, draw_handle: &mut dyn DrawHandle) {
// This type assumes usage of kas_wgpu without a custom draw pipe:
type DrawIface = DrawIface<kas_wgpu::draw::DrawPipe<()>>;
if let Some(mut draw) = DrawIface::downcast_from(draw_handle.draw_device()) {
draw.circle(self.rect.into(), 0.9, Rgba::BLACK);
}
}
}
Note that this object is little more than a mutable reference to the shell’s
per-window draw state. As such, it is normal to pass a new copy created
via DrawIface::reborrow
as a method argument. (Note that Rust automatically
“reborrows” reference types passed as method arguments, but cannot do so
automatically for structs containing references.)
Implementations
Attempt to downcast a &mut dyn Draw
to a concrete DrawIface
object
Reborrow with a new lifetime
Add a draw pass
Adds a new draw pass. Passes affect draw order (operations in new passes
happen after their parent pass), may clip drawing to a “clip rect”
(see DrawIface::get_clip_rect
) and may offset (translate) draw
operations.
Case class == PassType::Clip
: the new pass is derived from
parent_pass
; rect
and offset
are specified relative to this parent
and the intersecton of rect
and the parent’s “clip rect” is used.
be clipped to rect
(expressed in the parent’s coordinate system).
Case class == PassType::Overlay
: the new pass is derived from the
base pass (i.e. the window). Draw operations still happen after those in
parent_pass
.
Trait Implementations
pub fn get_fields_as_any_mut(
&mut self
) -> (&mut (dyn Any + 'static), &mut (dyn Any + 'static))
Add a draw pass Read more
Get drawable rect for a draw pass
Read more
Draw a frame of uniform colour Read more
Draw text with a colour
pub fn text_col_effects(
&mut self,
pos: Vec2,
text: &TextDisplay,
col: Rgba,
effects: &[Effect<()>]
)
pub fn text_col_effects(
&mut self,
pos: Vec2,
text: &TextDisplay,
col: Rgba,
effects: &[Effect<()>]
)
Draw text with a colour and effects Read more
Draw text with effects Read more
impl<'a, DS> DrawRounded for DrawIface<'a, DS> where
DS: DrawSharedImpl,
<DS as DrawSharedImpl>::Draw: DrawRoundedImpl,
impl<'a, DS> DrawRounded for DrawIface<'a, DS> where
DS: DrawSharedImpl,
<DS as DrawSharedImpl>::Draw: DrawRoundedImpl,
impl<'a, DS> DrawShaded for DrawIface<'a, DS> where
DS: DrawSharedImpl,
<DS as DrawSharedImpl>::Draw: DrawShadedImpl,
impl<'a, DS> DrawShaded for DrawIface<'a, DS> where
DS: DrawSharedImpl,
<DS as DrawSharedImpl>::Draw: DrawShadedImpl,
Auto Trait Implementations
impl<'a, DS> RefUnwindSafe for DrawIface<'a, DS> where
DS: RefUnwindSafe,
<DS as DrawSharedImpl>::Draw: RefUnwindSafe,
impl<'a, DS> !UnwindSafe for DrawIface<'a, DS>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
pub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
pub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
pub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
pub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
pub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
pub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more