This commit is contained in:
Able 2021-11-28 14:02:47 -06:00
commit 134f6d0ae4
3 changed files with 50 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target
Cargo.lock

8
Cargo.toml Normal file
View file

@ -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]

40
src/lib.rs Normal file
View file

@ -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);
}