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

Get the current draw pass

Add a draw pass Read more

Get drawable rect for a draw pass Read more

Draw a rectangle of uniform colour Read more

Draw a frame of uniform colour Read more

Draw the image in the given rect

Draw text with a colour

Draw text with a colour and effects Read more

Draw text with effects Read more

Draw a line with rounded ends and uniform colour Read more

Draw a circle or oval of uniform colour Read more

Draw a circle or oval with two colours Read more

Draw a frame with rounded corners and uniform colour Read more

Draw a frame with rounded corners with two colours Read more

Add a shaded square to the draw buffer Read more

Add a shaded circle to the draw buffer Read more

Add a shaded frame with square corners to the draw buffer

Add a shaded frame with rounded corners to the draw buffer

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Cast from Self to T

Try converting from Self to T

Cast to integer, truncating Read more

Cast to the nearest integer Read more

Cast the floor to an integer Read more

Cast the ceiling to an integer Read more

Try converting to integer with truncation Read more

Try converting to the nearest integer Read more

Try converting the floor to an integer Read more

Try convert the ceiling to an integer Read more

Convert from T to Self

Try converting from T to Self

Returns true if the given item matches this filter

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.