From 70a65fc10d2caafe370be90eb0e31aa7d9347218 Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 6 May 2023 05:13:52 -0500 Subject: [PATCH] update v2 --- .../src/raw_pixel/arch/x86/mod.rs | 30 +++++++++++++++++-- .../src/raw_pixel/mod.rs | 9 ++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libraries/able_graphics_library/src/raw_pixel/arch/x86/mod.rs b/libraries/able_graphics_library/src/raw_pixel/arch/x86/mod.rs index e802797..8e15c0f 100644 --- a/libraries/able_graphics_library/src/raw_pixel/arch/x86/mod.rs +++ b/libraries/able_graphics_library/src/raw_pixel/arch/x86/mod.rs @@ -1,12 +1,38 @@ use embedded_graphics::{ pixelcolor::Rgb888, - prelude::{DrawTarget, IntoStorage, OriginDimensions, Size}, - Pixel, + prelude::{DrawTarget, IntoStorage, OriginDimensions, PixelColor, Point, Size}, + primitives::{Line, Primitive, PrimitiveStyle}, + Drawable, Pixel, }; pub struct Display { pub fb: *mut u32, pub size: Size, + pub color: Rgb888, +} + +impl Display { + pub fn set_color(&mut self, color: Rgb888) { + self.color = color; + } + + pub fn line( + &mut self, + x1: i32, + y1: i32, + x2: i32, + y2: i32, + thickness: u32, + ) -> Result<(), BlitOutOfBoundsError> { + let color = self.color; + let style = PrimitiveStyle::with_stroke(color, thickness); + + Line::new(Point::new(x1, y1), Point::new(x2, y2)) + .into_styled(style) + .draw(&mut *self)?; + + Ok(()) + } } unsafe impl Send for Display {} diff --git a/libraries/able_graphics_library/src/raw_pixel/mod.rs b/libraries/able_graphics_library/src/raw_pixel/mod.rs index 3141cbe..44b438d 100644 --- a/libraries/able_graphics_library/src/raw_pixel/mod.rs +++ b/libraries/able_graphics_library/src/raw_pixel/mod.rs @@ -1,12 +1,9 @@ mod arch; +use core::fmt::Error; + use alloc::vec::Vec; pub use arch::x86::Display; -pub struct Color { - r: u8, - g: u8, - b: u8, - a: u8, -} +use self::arch::x86::BlitOutOfBoundsError;