update the graphics lib

pull/1/head
Able 2022-12-05 05:18:32 -06:00
parent f256b1cbfe
commit ac47ac2bd5
Signed by: able
GPG Key ID: 0BD8B45C30DCA887
6 changed files with 45 additions and 3 deletions

2
Cargo.lock generated
View File

@ -4,7 +4,7 @@ version = 3
[[package]]
name = "able_graphics_library"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"versioning",
]

View File

@ -1,6 +1,6 @@
[package]
name = "able_graphics_library"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -0,0 +1,33 @@
pub enum DisplayError {
InvalidFormat,
InvalidWidth,
InvalidHeight,
InvalidBPP,
InvalidFPS,
}
pub fn parse_display_string(s: &str) -> Result<(u32, u32, u32, u32), DisplayError> {
let parts: Vec<&str> = s.split('x').collect();
if parts.len() != 3 {
return Err(DisplayError::InvalidFormat);
}
let width = parts[0]
.parse::<u32>()
.map_err(|_| DisplayError::InvalidWidth)?;
let height = parts[1]
.parse::<u32>()
.map_err(|_| DisplayError::InvalidHeight)?;
let bits = parts[2].split('@').collect();
if bits.len() != 2 {
return Err(DisplayError::InvalidFormat);
}
let bpp = bits[0]
.parse::<u32>()
.map_err(|_| DisplayError::InvalidBPP)?;
let fps = bits[1]
.parse::<u32>()
.map_err(|_| DisplayError::InvalidFPS)?;
Ok((width, height, bpp, fps))
}

View File

@ -1,5 +1,7 @@
use core::ptr;
use alloc::vec::Vec;
use crate::color::Color3;
/// NOTE: Assumes the layout of RGBA
pub struct FrameBuffer {

View File

@ -1,3 +1,8 @@
#![no_std]
#[macro_use]
extern crate alloc;
pub mod buffer;
pub mod color;
pub mod commands;
@ -8,5 +13,5 @@ pub mod vertex;
pub const VERSION: versioning::Version = versioning::Version {
major: 0,
minor: 1,
patch: 0,
patch: 1,
};

View File

@ -1,3 +1,5 @@
use alloc::vec::Vec;
use crate::{
color::Color3,
types::{Float2Array, Float3Array, Position3},