Trait Layer

pub trait Layer: Default {
    // Required methods
    fn with_bounds(bounds: Rectangle) -> Self;
    fn bounds(&self) -> Rectangle;
    fn flush(&mut self);
    fn resize(&mut self, bounds: Rectangle);
    fn reset(&mut self);
    fn start(&self) -> usize;
    fn end(&self) -> usize;
    fn merge(&mut self, _layer: &mut Self);
}
Expand description

A layer of graphical primitives.

Layers normally dictate a set of primitives that are rendered in a specific order.

Required Methods§

fn with_bounds(bounds: Rectangle) -> Self

Creates a new Layer with the given bounds.

fn bounds(&self) -> Rectangle

Returns the current bounds of the Layer.

fn flush(&mut self)

Flushes and settles any pending group of primitives in the Layer.

This will be called when a Layer is finished. It allows layers to efficiently record primitives together and defer grouping until the end.

fn resize(&mut self, bounds: Rectangle)

Resizes the Layer to the given bounds.

fn reset(&mut self)

Clears all the layers contents and resets its bounds.

fn start(&self) -> usize

Returns the start level of the Layer.

A level is a “sublayer” index inside of a Layer.

A Layer may draw multiple primitive types in a certain order. The level represents the lowest index of the primitive types it contains.

Two layers A and B can therefore be merged if they have the same bounds, and the end level of A is lower or equal than the start level of B.

fn end(&self) -> usize

Returns the end level of the Layer.

fn merge(&mut self, _layer: &mut Self)

Merges a Layer with the current one.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl Layer for Layer

§

fn with_bounds(bounds: Rectangle) -> Layer

§

fn bounds(&self) -> Rectangle

§

fn flush(&mut self)

§

fn resize(&mut self, bounds: Rectangle)

§

fn reset(&mut self)

§

fn start(&self) -> usize

§

fn end(&self) -> usize

§

fn merge(&mut self, layer: &mut Layer)

Implementors§