Module kas::draw[][src]

Expand description

Draw APIs

Multiple drawing APIs are available. Each has a slightly different purpose.

High-level themeable interface

When widgets are sized or drawn, they are provided a SizeHandle or a DrawHandle trait object. A SizeHandle may also be obtained through crate::event::Manager::size_handle.

These traits are implemented by the theme of choice, providing a high-level themed API over “widget features”.

SizeHandle is the only part of the API providing sizing data. If drawing via a lower-level API, it may still be necessary to query the scale factor or some feature size via SizeHandle.

Medium-level drawing interfaces

The theme draws widget components over a DrawIface object. Widgets may access this same API via DrawHandle::draw_device.

The traits Draw and DrawRounded provide functinality over a DrawIface object. Additional interfaces may be defined in external crates.

Low-level interface

There is no universal graphics API, hence none is provided by this crate. Instead, shells may provide their own extensions allowing direct access to the host graphics API, for example kas-wgpu::draw::CustomPipe. The mandlebrot example demonstrates use of a custom draw pipe.

Draw order

All draw operations happen within a “draw pass”. The first pass corresponds to the window, while additional passes may be clipped and offset (see DrawIface::new_pass). Draw passes are executed sequentially in the order defined.

Within each pass, draw operations may be batched by the shell, thus draw operations may not happen in the order queued. In general, it may be expected that batches are executed in the following order:

  1. Square-edged primitives (e.g. Draw::rect)
  2. Images
  3. Rounded or other partially-transparent primitives (e.g. DrawRounded::circle)
  4. Custom draw routines (CustomPipe)
  5. Text

Modules

Colour types

Structs

Draw interface object

Identifier for an image allocation

Input and highlighting state of a widget

Draw pass identifier

Shared draw state

Enums

Image loading errors

Image formats available for upload

Type of draw pass

Class of text drawn

Traits

Base drawing interface for DrawIface

A handle to the active theme, used for drawing

Extension trait over DrawHandle

Extension over Draw for rounded shapes

Interface over SharedState

A handle to the active theme, used for sizing

Interface through which a theme can be adjusted at run-time