pub struct Controller { /* private fields */ }Expand description
A controller of layers.
Implementations§
Source§impl Controller
impl Controller
Sourcepub unsafe fn new(
resolution: Vec2<u32>,
bits_per_pixel: u32,
base_addr_of_vram: usize,
) -> Self
pub unsafe fn new( resolution: Vec2<u32>, bits_per_pixel: u32, base_addr_of_vram: usize, ) -> Self
Creates an instance of this type.
§Safety
This function is unsafe because this library may break memory safety by trying to access an
invalid memory if base_addr_of_vram is not a correct address.
Also this library may access to the memory outside of VRAM if resolution contains larger
value than the actual one.
Sourcepub fn add_layer(&mut self, layer: Layer) -> Id
pub fn add_layer(&mut self, layer: Layer) -> Id
Add a layer.
This method returns an ID of the layer. You must save the id to edit the one.
Added layer comes to the front. All layers behind the one will be hidden.
After adding a layer, layers will be redrawn.
Sourcepub fn edit_layer<T>(&mut self, id: Id, f: T) -> Result<(), Error>
pub fn edit_layer<T>(&mut self, id: Id, f: T) -> Result<(), Error>
Edit a layer.
You can edit a layer by indexing Layer type. For more information, see the description of
Index implementation of Layer type.
After editing, layers will be redrawn. This may take time if the layer is large. In such
cases, use [set_pixel] instead.
Sourcepub fn set_pixel(
&mut self,
id: Id,
coord: Vec2<u32>,
color: Option<RGB8>,
) -> Result<(), Error>
pub fn set_pixel( &mut self, id: Id, coord: Vec2<u32>, color: Option<RGB8>, ) -> Result<(), Error>
Set a color on pixel.
coord is the coordinate of the relative position from the top-left of the layer. If color is None, the pixel is transparent.
After editing, only the edited pixel will be redrawn.
Sourcepub fn slide_layer(
&mut self,
id: Id,
new_top_left: Vec2<i32>,
) -> Result<(), Error>
pub fn slide_layer( &mut self, id: Id, new_top_left: Vec2<i32>, ) -> Result<(), Error>
Slide a layer.
The value of new_top_left can be negative, or larger than screen resolution. In such
cases, any part of the layer that extends outside the screen will not be drawn.
After sliding, layers will be redrawn.