Commit Diff


commit - 6d3901c2bbb03cab82d3a67555738bc84dd7faa2
commit + e4b3bdecac0878c575ac410513582983b59f82eb
blob - f44e934027f2c0dde619bc3bb5678aa4e4d4effe
blob + 80942aa10242e5df4a275e3fbee886492b0beb37
--- src/drivers/video_driver.rs
+++ src/drivers/video_driver.rs
@@ -13,14 +13,17 @@ pub struct VideoDriver {
 impl VideoDriver {
     /// Create a new window.
     pub fn new() -> Self {
-        let mut w = Window::new("yac8e", 64, 32, WindowOptions::default()).expect("Unable to open a window");
+        let mut w = Window::new("yac8e", 64, 32, WindowOptions::default())
+            .expect("Unable to open a window");
 
         Self { window: w }
     }
 
     /// Draw the given array to the window.
     pub fn draw(&mut self, pixels: &[u32; WINDOW_WIDTH * WINDOW_HEIGHT]) {
-        self.window.update_with_buffer(pixels, WINDOW_WIDTH, WINDOW_HEIGHT).expect("Wrong buffer size");
+        self.window
+            .update_with_buffer(pixels, WINDOW_WIDTH, WINDOW_HEIGHT)
+            .expect("Wrong buffer size");
     }
 
     /// Clears the window.
@@ -28,3 +31,9 @@ impl VideoDriver {
         todo!();
     }
 }
+
+pub fn from_u8_rgb(r: u8, g: u8, b: u8) -> u32 {
+    let (r, g, b) = (r as u32, g as u32, b as u32);
+
+    (r << 16) | (g << 8) | b
+}