screen_layer

This crate provides layer structure of the screen, which is useful for developing an OS.

This crate uses features of alloc crate, so you have to extern alloc crate. This means you have to define your own heap allocator.

Currently this crate only supports 24 or 32 bits color of BGR order.

Examples

```rust use screen_layer::{self, Layer, Vec2, RGB8};

const SCREENWIDTH: usize = 10; const SCREENHEIGHT: usize = 10; const BPP: usize = 32; let mut pseudovram = [0u8; SCREENWIDTH * SCREENHEIGHT * BPP / 8]; let ptr = pseudovram.asptr() as usize; let mut controller = unsafe { screenlayer::Controller::new(Vec2::new(SCREENWIDTH, SCREENHEIGHT), BPP, ptr) };

const LAYERWIDTH: usize = 5; const LAYERHEIGHT: usize = 5; let layer = Layer::new(Vec2::new(0, 0), Vec2::new(LAYERWIDTH, LAYERHEIGHT)); let id = controller.add_layer(layer);

controller .editlayer(id, |layer: &mut Layer| { for i in 0..LAYERWIDTH { layer[i][i] = Some(RGB8::new(0, 255, 0)); } }) .unwrap();

for i in 0..LAYERWIDTH { asserteq!(pseudovram[BPP / 8 * (i * SCREENWIDTH + i)], 0); asserteq!(pseudovram[BPP / 8 * (i * SCREENWIDTH + i) + 1], 255); asserteq!(pseudovram[BPP / 8 * (i * SCREENWIDTH + i) + 2], 0); } ```

License: MPL-2.0