Controller

Struct Controller 

Source
pub struct Controller { /* private fields */ }
Expand description

A controller of layers.

Implementations§

Source§

impl Controller

Source

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.

Source

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.

Source

pub fn edit_layer<T>(&mut self, id: Id, f: T) -> Result<(), Error>
where T: Fn(&mut Layer),

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Controller

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Controller

Source§

fn default() -> Controller

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.