update the graphics lib

This commit is contained in:
Able 2022-12-05 05:18:32 -06:00
parent e6f835d6ae
commit 469325b52a
6 changed files with 45 additions and 3 deletions

2
Cargo.lock generated
View file

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

View file

@ -1,6 +1,6 @@
[package] [package]
name = "able_graphics_library" name = "able_graphics_library"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # 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 core::ptr;
use alloc::vec::Vec;
use crate::color::Color3; use crate::color::Color3;
/// NOTE: Assumes the layout of RGBA /// NOTE: Assumes the layout of RGBA
pub struct FrameBuffer { pub struct FrameBuffer {

View file

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

View file

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