commit 04b16fbc221eb339e02a07d184914bf2f07865ca Author: Able Date: Sun Nov 28 14:02:47 2021 -0600 AGL diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9a47a01 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "able_graphics_library" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..fcf40e7 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,40 @@ +#![allow(dead_code, unused)] + +#[derive(Clone, Debug, Copy)] +pub struct RGBA { + pub r: u8, + pub g: u8, + pub b: u8, + pub a: u8, +} + +pub const WIDTH: usize = 600; +pub const HEIGHT: usize = 400; + +pub type FrameBuffer = [RGBA; WIDTH * HEIGHT]; + +pub struct Point { + pub x: u16, + pub y: u16, +} +pub trait AglApi { + fn put_line(&mut self, coords_start: Point, coords_end: Point, thickness: u32, color: RGBA); + fn put_rect(&mut self, coords_start: Point, coords_end: Point, color: RGBA); + fn put_circle(&mut self, coords: Point, radius: u32); + fn put_pixel(&mut self, coords: Point, color: RGBA); + fn put_triangle( + &mut self, + coords_1: Point, + coords_2: Point, + coords_3: Point, + thickness: u32, + color: RGBA, + ); + fn paint_cursor(&mut self, coords: Point); + fn hide_cursor(); + fn show_cursor(); + /// Actually move the double buffer to the single buffer and "update" the screen + fn draw(&mut self); + /// Setup the clear color to be used + fn clear(&mut self, color: RGBA); +}