Struct radiant_rs::Layer
[−]
[src]
pub struct Layer { /* fields omitted */ }
A non-blocking, thread-safe drawing surface.
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 onto the display. Layers can be rendered multiple times using different matrices, blendmodes or colors without having to redraw their contents first.
Multiple threads can draw onto the same layer without blocking. However, manipulating layer properties may block other threads from manipulating the same property.
Methods
impl Layer
[src]
fn new<T>(dimensions: T, channel_id: u32) -> Self where Vec2<f32>: From<T>
Creates a new layer with given dimensions. The channel determines which sprite channel is drawn. All sprites support at least channel 0. Nothing will be drawn if the sprite does not contain given channel.
fn new_with_program<T>(dimensions: T, channel_id: u32, program: Program) -> Self where Vec2<f32>: From<T>
Creates a new layer with given dimensions and fragment program. The channel determines which sprite channel is drawn. All sprites support at least channel 0. Nothing will be drawn if the sprite does not contain given channel.
fn set_color(&self, color: Color) -> &Self
Sets a global color multiplicator. Setting this to white means that the layer contents are renderered in their original colors.
Note that Color
s 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.
fn color(&self) -> MutexGuard<Color>
Returns a mutex guarded mutable reference to the global color multiplicator.
fn set_view_matrix(&self, matrix: Mat4<f32>) -> &Self
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.
fn view_matrix(&self) -> MutexGuard<Mat4<f32>>
Returns a mutex guarded mutable reference to the view matrix.
See set_view_matrix()
for a description of the view matrix.
fn set_model_matrix(&self, matrix: Mat4<f32>) -> &Self
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.
fn model_matrix(&self) -> MutexGuard<Mat4<f32>>
Returns a mutex guarded mutable reference to the model matrix.
See set_model_matrix()
for a description of the model matrix.
fn set_blendmode(&self, blendmode: BlendMode) -> &Self
Sets the blendmode.
fn blendmode(&self) -> MutexGuard<BlendMode>
Returns a mutex guarded mutable reference to the blendmode.
fn clear(&self) -> &Self
Removes all previously added object from the layer. Typically invoked after the layer has been rendered.
fn capacity(&self) -> usize
Returns the number of sprites the layer can hold without having to perform a blocking reallocation.
fn len(&self) -> usize
Returns the number of sprites currently stored the layer.
fn arc(self) -> Arc<Self>
Returns the layer wrapped in an std::Arc