Struct radiant_rs::Layer[][src]

pub struct Layer { /* fields omitted */ }

A drawing surface for text and sprites that implements send+sync and is wait-free for drawing operations.

In radiant_rs, sprite drawing happens on layers. Layers provide transformation capabilities in the form of model- and view-matrices and the layer's blendmode and color determine how sprites are rendered to the drawing target. Layers can be rendered multiple times using different matrices, blendmodes or colors without having to redraw their contents first.

For convenience, layers are created with a view-matrix that maps the given dimensions to the entirety of the drawing target. The layer itself is infinite though, and can be transformed at any time before rendering.

Drawing to a layer is a wait-free atomic operation that can be safely performed from multiple threads at the same time. Modifying layer properties like the matrices may cause other threads to wait.

Methods

impl Layer
[src]

Creates a new layer with given dimensions, meaning that is is created with a view matrix that maps the given dimensions to the entirety of the drawing target.

Creates a new layer with given dimensions and fragment program.

Creates a new layer that references the contents of this layer but has its own color, blendmode, program and set of matrices.

Important traits for &'a mut R

Sets a global color multiplicator. Setting this to white means that the layer contents are renderered in their original colors.

Note that Colors contain alpha information and are not clamped to any range, so it is possible to use an overbright color to brighten the result or use the alpha channel to apply global transparency.

Returns a mutex guarded mutable reference to the global color multiplicator.

Important traits for &'a mut R

Sets the view matrix.

View matrix transformation is applied after the objects are fully positioned on the layer. As a result, manipulating the view matrix has the effect of manipulating the layer itself, e.g. rotating the entire layer.

Returns a mutex guarded mutable reference to the view matrix. See set_view_matrix() for a description of the view matrix.

Important traits for &'a mut R

Sets the model matrix.

Model matrix transformation is applied before each object is transformed to its position on the layer. As a result, manipulating the model matrix has the effect of manipulating every object on the layer in the same way, e.g. rotating every individual object on the layer around a point relative to the individual object.

Returns a mutex guarded mutable reference to the model matrix. See set_model_matrix() for a description of the model matrix.

Important traits for &'a mut R

Sets the blendmode.

Returns a mutex guarded mutable reference to the blendmode.

Important traits for &'a mut R

Removes all previously added objects from the layer. Typically invoked after the layer has been rendered.

Returns the number of sprites the layer can hold without having to perform a blocking reallocation.

Returns the number of sprites currently stored the layer.

Returns the layer wrapped in an std::Arc.

Returns a reference to the program used by this layer.

Trait Implementations

impl Debug for Layer
[src]

Formats the value using the given formatter. Read more

impl Send for Layer
[src]

impl Sync for Layer
[src]

impl Clone for Layer
[src]

Creates a new layer that references the contents of this layer but has its own color, blendmode and set of matrices.

Performs copy-assignment from source. Read more