From 6f8099d80017f7c357950d75244b77455b4f7607 Mon Sep 17 00:00:00 2001 From: gamirab Date: Fri, 26 Jul 2024 17:22:00 +0200 Subject: [PATCH] More intuitive color use for the draw_text function (#123) * More intuitive color use for the draw_text function potentially, add background (this is for foreground color) * rust fmt * removing dead code --- src/framebuffer/draw.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/framebuffer/draw.rs b/src/framebuffer/draw.rs index b13c083..60a06ab 100644 --- a/src/framebuffer/draw.rs +++ b/src/framebuffer/draw.rs @@ -191,13 +191,16 @@ impl framebuffer::FramebufferDraw for core::Framebuffer { } glyph.draw(|x, y, v| { - let mult = (1.0 - v).min(1.0); self.write_pixel( Point2 { x: (x + bounding_box.min.x as u32) as i32, y: (y + bounding_box.min.y as u32) as i32, }, - color::RGB((c1 * mult) as u8, (c2 * mult) as u8, (c3 * mult) as u8), + color::RGB( + (255.0 + (c1 - 255.0) * v) as u8, + (255.0 + (c2 - 255.0) * v) as u8, + (255.0 + (c3 - 255.0) * v) as u8, + ), ) }); }