diff --git a/examples/imgui_integration/src/context.rs b/examples/imgui_integration/src/context.rs index b168181..e604fac 100644 --- a/examples/imgui_integration/src/context.rs +++ b/examples/imgui_integration/src/context.rs @@ -11,7 +11,7 @@ pub struct CoreContext { pub delta: f32, pub camera_x: i32, pub camera_y: i32, - pub transparent_color: ARGBu8x4, + pub transparent_color: ARGB, pub system: System, pub palette: Palette, pub font: BitmaskFont, diff --git a/examples/imgui_integration/src/tilemap.rs b/examples/imgui_integration/src/tilemap.rs index cdf20c4..900af5e 100644 --- a/examples/imgui_integration/src/tilemap.rs +++ b/examples/imgui_integration/src/tilemap.rs @@ -63,7 +63,7 @@ impl TileMap { tiles: &BitmapAtlas, camera_x: i32, camera_y: i32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, ) { let xt = camera_x / TILE_WIDTH as i32; let yt = camera_y / TILE_HEIGHT as i32; diff --git a/ggdt/benches/bitmap.rs b/ggdt/benches/bitmap.rs index 555aacc..d8ed7d0 100644 --- a/ggdt/benches/bitmap.rs +++ b/ggdt/benches/bitmap.rs @@ -7,7 +7,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { let height = 240; let mut source = IndexedBitmap::new(width, height).unwrap(); - let mut dest = vec![ARGBu8x4::default(); (width * height) as usize].into_boxed_slice(); + let mut dest = vec![ARGB::default(); (width * height) as usize].into_boxed_slice(); let palette = Palette::new_vga_palette().unwrap(); c.bench_function("deindex_bitmap_pixels", |b| b.iter(|| source.copy_as_argb_to(&mut dest, &palette))); diff --git a/ggdt/benches/primitives.rs b/ggdt/benches/primitives.rs index d6e186e..ddc93f6 100644 --- a/ggdt/benches/primitives.rs +++ b/ggdt/benches/primitives.rs @@ -6,9 +6,9 @@ pub fn criterion_benchmark(c: &mut Criterion) { let width = 320; let height = 240; - const BG_COLOR: ARGBu8x4 = ARGBu8x4::from_rgb([0, 0, 0]); - const SOLID_COLOR: ARGBu8x4 = ARGBu8x4::from_rgb([255, 0, 255]); - const BLEND_COLOR: ARGBu8x4 = ARGBu8x4::from_argb([127, 255, 0, 255]); + const BG_COLOR: ARGB = ARGB::from_rgb([0, 0, 0]); + const SOLID_COLOR: ARGB = ARGB::from_rgb([255, 0, 255]); + const BLEND_COLOR: ARGB = ARGB::from_argb([127, 255, 0, 255]); let mut dest = RgbaBitmap::new(width, height).unwrap(); diff --git a/ggdt/benches/triangles.rs b/ggdt/benches/triangles.rs index 3e2585c..59a1ed8 100644 --- a/ggdt/benches/triangles.rs +++ b/ggdt/benches/triangles.rs @@ -22,10 +22,10 @@ pub fn criterion_benchmark(c: &mut Criterion) { let texcoord_0_1 = Vector2::new(0.0, 1.0); let texcoord_1_1 = Vector2::new(1.0, 1.0); - let color = ARGBu8x4::from_rgb([255, 255, 255]); - let color_1 = ARGBu8x4::from_argb([255, 255, 0, 0]); - let color_2 = ARGBu8x4::from_argb([255, 0, 255, 0]); - let color_3 = ARGBu8x4::from_argb([255, 0, 0, 255]); + let color = ARGB::from_rgb([255, 255, 255]); + let color_1 = ARGB::from_argb([255, 255, 0, 0]); + let color_2 = ARGB::from_argb([255, 0, 255, 0]); + let color_3 = ARGB::from_argb([255, 0, 0, 255]); c.bench_function("rgbabitmap_triangle_2d_solid_color", |b| { let triangle = RgbaTriangle2d::Solid { position: [big_v1, big_v2, big_v3], color }; diff --git a/ggdt/src/graphics/bitmap/general.rs b/ggdt/src/graphics/bitmap/general.rs index 7b7d717..43815eb 100644 --- a/ggdt/src/graphics/bitmap/general.rs +++ b/ggdt/src/graphics/bitmap/general.rs @@ -7,7 +7,7 @@ //! Only a subset of the most common Bitmap drawing operations will be provided here. use crate::graphics::{ - ARGBu8x4, BitmapError, Font, FontRenderOpts, IndexedBitmap, IndexedBlitMethod, Pixel, RgbaBitmap, RgbaBlitMethod, + BitmapError, Font, FontRenderOpts, IndexedBitmap, IndexedBlitMethod, Pixel, RgbaBitmap, RgbaBlitMethod, ARGB, }; use crate::math::Rect; @@ -220,7 +220,7 @@ impl GeneralBitmap for IndexedBitmap { } impl GeneralBitmap for RgbaBitmap { - type PixelType = ARGBu8x4; + type PixelType = ARGB; #[inline] fn new(width: u32, height: u32) -> Result { diff --git a/ggdt/src/graphics/bitmap/indexed/mod.rs b/ggdt/src/graphics/bitmap/indexed/mod.rs index 49fbf5b..5478db7 100644 --- a/ggdt/src/graphics/bitmap/indexed/mod.rs +++ b/ggdt/src/graphics/bitmap/indexed/mod.rs @@ -1,6 +1,6 @@ use std::path::Path; -use crate::graphics::{ARGBu8x4, Bitmap, BitmapError, Palette, RgbaBitmap}; +use crate::graphics::{Bitmap, BitmapError, Palette, RgbaBitmap, ARGB}; mod blit; mod primitives; @@ -51,7 +51,7 @@ impl IndexedBitmap { /// /// * `dest`: destination 32-bit ARGB pixel buffer to copy converted pixels to /// * `palette`: the 256 colour palette to use during pixel conversion - pub fn copy_as_argb_to(&self, dest: &mut [ARGBu8x4], palette: &Palette) { + pub fn copy_as_argb_to(&self, dest: &mut [ARGB], palette: &Palette) { for (src, dest) in self.pixels().iter().zip(dest.iter_mut()) { *dest = palette[*src]; } diff --git a/ggdt/src/graphics/bitmap/png.rs b/ggdt/src/graphics/bitmap/png.rs index 593b646..fe34656 100644 --- a/ggdt/src/graphics/bitmap/png.rs +++ b/ggdt/src/graphics/bitmap/png.rs @@ -7,7 +7,7 @@ use std::path::Path; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use thiserror::Error; -use crate::graphics::{ARGBu8x4, Bitmap, IndexedBitmap, Palette, PaletteError, PaletteFormat, Pixel, RgbaBitmap}; +use crate::graphics::{Bitmap, IndexedBitmap, Palette, PaletteError, PaletteFormat, Pixel, RgbaBitmap, ARGB}; use crate::utils::ReadFixedLengthByteArray; const PNG_HEADER: [u8; 8] = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]; @@ -319,8 +319,8 @@ impl ScanlinePixelConverter for ScanlineBuffer { } } -impl ScanlinePixelConverter for ScanlineBuffer { - fn read_pixel(&mut self, x: usize, palette: &Option) -> Result { +impl ScanlinePixelConverter for ScanlineBuffer { + fn read_pixel(&mut self, x: usize, palette: &Option) -> Result { let offset = x * self.bpp; match self.format { ColorFormat::IndexedColor => { @@ -337,20 +337,20 @@ impl ScanlinePixelConverter for ScanlineBuffer { let r = self.current[offset]; let g = self.current[offset + 1]; let b = self.current[offset + 2]; - Ok(ARGBu8x4::from_rgb([r, g, b])) + Ok(ARGB::from_rgb([r, g, b])) } ColorFormat::RGBA => { let r = self.current[offset]; let g = self.current[offset + 1]; let b = self.current[offset + 2]; let a = self.current[offset + 3]; - Ok(ARGBu8x4::from_argb([a, r, g, b])) + Ok(ARGB::from_argb([a, r, g, b])) } _ => Err(PngError::BadFile(format!("Unsupported color format for this PixelReader: {:?}", self.format))), } } - fn write_pixel(&mut self, x: usize, pixel: ARGBu8x4) -> Result<(), PngError> { + fn write_pixel(&mut self, x: usize, pixel: ARGB) -> Result<(), PngError> { let offset = x * self.bpp; match self.format { ColorFormat::RGB => { diff --git a/ggdt/src/graphics/bitmap/rgb/blit.rs b/ggdt/src/graphics/bitmap/rgb/blit.rs index b6f995c..606c807 100644 --- a/ggdt/src/graphics/bitmap/rgb/blit.rs +++ b/ggdt/src/graphics/bitmap/rgb/blit.rs @@ -1,6 +1,6 @@ use crate::graphics::{ - clip_blit, per_pixel_blit, per_pixel_flipped_blit, per_pixel_rotozoom_blit, ARGBu8x4, BitmapAtlas, BlendFunction, - RgbaBitmap, + clip_blit, per_pixel_blit, per_pixel_flipped_blit, per_pixel_rotozoom_blit, BitmapAtlas, BlendFunction, RgbaBitmap, + ARGB, }; use crate::math::Rect; @@ -8,7 +8,7 @@ use crate::math::Rect; pub enum RgbaBlitMethod { /// Solid blit, no transparency or other per-pixel adjustments. Solid, - SolidTinted(ARGBu8x4), + SolidTinted(ARGB), SolidBlended(BlendFunction), /// Same as [RgbaBlitMethod::Solid] but the drawn image can also be flipped horizontally /// and/or vertically. @@ -19,7 +19,7 @@ pub enum RgbaBlitMethod { SolidFlippedTinted { horizontal_flip: bool, vertical_flip: bool, - tint_color: ARGBu8x4, + tint_color: ARGB, }, SolidFlippedBlended { horizontal_flip: bool, @@ -27,30 +27,30 @@ pub enum RgbaBlitMethod { blend: BlendFunction, }, /// Transparent blit, the specified source color pixels are skipped. - Transparent(ARGBu8x4), + Transparent(ARGB), TransparentTinted { - transparent_color: ARGBu8x4, - tint_color: ARGBu8x4, + transparent_color: ARGB, + tint_color: ARGB, }, TransparentBlended { - transparent_color: ARGBu8x4, + transparent_color: ARGB, blend: BlendFunction, }, /// Same as [RgbaBlitMethod::Transparent] but the drawn image can also be flipped horizontally /// and/or vertically. TransparentFlipped { - transparent_color: ARGBu8x4, + transparent_color: ARGB, horizontal_flip: bool, vertical_flip: bool, }, TransparentFlippedTinted { - transparent_color: ARGBu8x4, + transparent_color: ARGB, horizontal_flip: bool, vertical_flip: bool, - tint_color: ARGBu8x4, + tint_color: ARGB, }, TransparentFlippedBlended { - transparent_color: ARGBu8x4, + transparent_color: ARGB, horizontal_flip: bool, vertical_flip: bool, blend: BlendFunction, @@ -58,15 +58,15 @@ pub enum RgbaBlitMethod { /// Same as [RgbaBlitMethod::Transparent] except that the visible pixels on the destination are all /// drawn using the same color. TransparentSingle { - transparent_color: ARGBu8x4, - draw_color: ARGBu8x4, + transparent_color: ARGB, + draw_color: ARGB, }, /// Combination of [RgbaBlitMethod::TransparentFlipped] and [RgbaBlitMethod::TransparentSingle]. TransparentFlippedSingle { - transparent_color: ARGBu8x4, + transparent_color: ARGB, horizontal_flip: bool, vertical_flip: bool, - draw_color: ARGBu8x4, + draw_color: ARGB, }, /// Rotozoom blit, works the same as [RgbaBlitMethod::Solid] except that rotation and scaling is /// performed. @@ -79,7 +79,7 @@ pub enum RgbaBlitMethod { angle: f32, scale_x: f32, scale_y: f32, - tint_color: ARGBu8x4, + tint_color: ARGB, }, RotoZoomBlended { angle: f32, @@ -92,20 +92,20 @@ pub enum RgbaBlitMethod { angle: f32, scale_x: f32, scale_y: f32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, }, RotoZoomTransparentTinted { angle: f32, scale_x: f32, scale_y: f32, - transparent_color: ARGBu8x4, - tint_color: ARGBu8x4, + transparent_color: ARGB, + tint_color: ARGB, }, RotoZoomTransparentBlended { angle: f32, scale_x: f32, scale_y: f32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, blend: BlendFunction, }, } @@ -117,7 +117,7 @@ impl RgbaBitmap { src_region: &Rect, dest_x: i32, dest_y: i32, - tint_color: ARGBu8x4, + tint_color: ARGB, ) { per_pixel_blit( self, // @@ -183,7 +183,7 @@ impl RgbaBitmap { dest_y: i32, horizontal_flip: bool, vertical_flip: bool, - tint_color: ARGBu8x4, + tint_color: ARGB, ) { per_pixel_flipped_blit( self, // @@ -205,8 +205,8 @@ impl RgbaBitmap { src_region: &Rect, dest_x: i32, dest_y: i32, - transparent_color: ARGBu8x4, - tint_color: ARGBu8x4, + transparent_color: ARGB, + tint_color: ARGB, ) { per_pixel_blit( self, // @@ -228,7 +228,7 @@ impl RgbaBitmap { src_region: &Rect, dest_x: i32, dest_y: i32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, blend: BlendFunction, ) { per_pixel_blit( @@ -251,10 +251,10 @@ impl RgbaBitmap { src_region: &Rect, dest_x: i32, dest_y: i32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, horizontal_flip: bool, vertical_flip: bool, - tint_color: ARGBu8x4, + tint_color: ARGB, ) { per_pixel_flipped_blit( self, // @@ -278,7 +278,7 @@ impl RgbaBitmap { src_region: &Rect, dest_x: i32, dest_y: i32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, horizontal_flip: bool, vertical_flip: bool, blend: BlendFunction, @@ -308,7 +308,7 @@ impl RgbaBitmap { angle: f32, scale_x: f32, scale_y: f32, - tint_color: ARGBu8x4, + tint_color: ARGB, ) { per_pixel_rotozoom_blit( self, // @@ -362,8 +362,8 @@ impl RgbaBitmap { angle: f32, scale_x: f32, scale_y: f32, - transparent_color: ARGBu8x4, - tint_color: ARGBu8x4, + transparent_color: ARGB, + tint_color: ARGB, ) { per_pixel_rotozoom_blit( self, // @@ -391,7 +391,7 @@ impl RgbaBitmap { angle: f32, scale_x: f32, scale_y: f32, - transparent_color: ARGBu8x4, + transparent_color: ARGB, blend: BlendFunction, ) { per_pixel_rotozoom_blit( diff --git a/ggdt/src/graphics/bitmap/rgb/mod.rs b/ggdt/src/graphics/bitmap/rgb/mod.rs index b86438f..96460bf 100644 --- a/ggdt/src/graphics/bitmap/rgb/mod.rs +++ b/ggdt/src/graphics/bitmap/rgb/mod.rs @@ -1,7 +1,7 @@ use byteorder::ReadBytesExt; use std::path::Path; -use crate::graphics::{ARGBu8x4, Bitmap, BitmapError, Palette}; +use crate::graphics::{Bitmap, BitmapError, Palette, ARGB}; mod blit; mod primitives; @@ -11,7 +11,7 @@ pub use blit::*; pub use primitives::*; pub use triangles::*; -pub type RgbaBitmap = Bitmap; +pub type RgbaBitmap = Bitmap; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum RgbaPixelFormat { @@ -29,7 +29,7 @@ impl RgbaBitmap { /// /// returns: `Result` pub fn new(width: u32, height: u32) -> Result { - Self::internal_new(width, height, ARGBu8x4::from_rgb([0, 0, 0])) + Self::internal_new(width, height, ARGB::from_rgb([0, 0, 0])) } pub fn from_bytes( @@ -38,7 +38,7 @@ impl RgbaBitmap { format: RgbaPixelFormat, reader: &mut T, ) -> Result { - let mut bitmap = Self::internal_new(width, height, ARGBu8x4::from_rgb([0, 0, 0]))?; + let mut bitmap = Self::internal_new(width, height, ARGB::from_rgb([0, 0, 0]))?; for pixel in bitmap.pixels_mut().iter_mut() { *pixel = match format { RgbaPixelFormat::RGBA => { @@ -46,14 +46,14 @@ impl RgbaBitmap { let g = reader.read_u8()?; let b = reader.read_u8()?; let a = reader.read_u8()?; - ARGBu8x4::from_argb([a, r, g, b]) + ARGB::from_argb([a, r, g, b]) } RgbaPixelFormat::ARGB => { let a = reader.read_u8()?; let r = reader.read_u8()?; let g = reader.read_u8()?; let b = reader.read_u8()?; - ARGBu8x4::from_argb([a, r, g, b]) + ARGB::from_argb([a, r, g, b]) } }; } diff --git a/ggdt/src/graphics/bitmap/rgb/primitives.rs b/ggdt/src/graphics/bitmap/rgb/primitives.rs index 0fc2278..18ad9f4 100644 --- a/ggdt/src/graphics/bitmap/rgb/primitives.rs +++ b/ggdt/src/graphics/bitmap/rgb/primitives.rs @@ -1,10 +1,10 @@ -use crate::graphics::{ARGBu8x4, BlendFunction, RgbaBitmap}; +use crate::graphics::{BlendFunction, RgbaBitmap, ARGB}; impl RgbaBitmap { /// Sets the pixel at the given coordinates using a blended color via the specified blend function /// If the coordinates lie outside of the bitmaps clipping region, no pixels will be changed. #[inline] - pub fn set_blended_pixel(&mut self, x: i32, y: i32, color: ARGBu8x4, blend: BlendFunction) { + pub fn set_blended_pixel(&mut self, x: i32, y: i32, color: ARGB, blend: BlendFunction) { self.set_custom_pixel( x, // y, @@ -16,7 +16,7 @@ impl RgbaBitmap { /// The coordinates are not checked for validity, so it is up to you to ensure they lie within the /// bounds of the bitmap. #[inline] - pub unsafe fn set_blended_pixel_unchecked(&mut self, x: i32, y: i32, color: ARGBu8x4, blend: BlendFunction) { + pub unsafe fn set_blended_pixel_unchecked(&mut self, x: i32, y: i32, color: ARGB, blend: BlendFunction) { self.set_custom_pixel_unchecked( x, // y, @@ -26,7 +26,7 @@ impl RgbaBitmap { /// Draws a line from x1,y1 to x2,y2 by blending the drawn pixels using the given blend function. #[inline] - pub fn blended_line(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ARGBu8x4, blend: BlendFunction) { + pub fn blended_line(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ARGB, blend: BlendFunction) { self.line_custom( x1, // y1, @@ -39,7 +39,7 @@ impl RgbaBitmap { /// Draws a horizontal line from x1,y to x2,y by blending the drawn pixels using the given /// blend function. #[inline] - pub fn blended_horiz_line(&mut self, x1: i32, x2: i32, y: i32, color: ARGBu8x4, blend: BlendFunction) { + pub fn blended_horiz_line(&mut self, x1: i32, x2: i32, y: i32, color: ARGB, blend: BlendFunction) { self.horiz_line_custom( x1, // x2, @@ -51,7 +51,7 @@ impl RgbaBitmap { /// Draws a vertical line from x,y1 to x,y2 by blending the drawn pixels using the given blend /// function. #[inline] - pub fn blended_vert_line(&mut self, x: i32, y1: i32, y2: i32, color: ARGBu8x4, blend: BlendFunction) { + pub fn blended_vert_line(&mut self, x: i32, y1: i32, y2: i32, color: ARGB, blend: BlendFunction) { self.vert_line_custom( x, // y1, @@ -64,7 +64,7 @@ impl RgbaBitmap { /// drawn, assuming they are specifying the top-left and bottom-right corners respectively. /// The box is drawn by blending the drawn pixels using the given blend function. #[inline] - pub fn blended_rect(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ARGBu8x4, blend: BlendFunction) { + pub fn blended_rect(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ARGB, blend: BlendFunction) { self.rect_custom( x1, // y1, @@ -78,7 +78,7 @@ impl RgbaBitmap { /// drawn, assuming they are specifying the top-left and bottom-right corners respectively. The /// filled box is draw by blending the drawn pixels using the given blend function. #[inline] - pub fn blended_filled_rect(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ARGBu8x4, blend: BlendFunction) { + pub fn blended_filled_rect(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ARGB, blend: BlendFunction) { self.filled_rect_custom( x1, // y1, diff --git a/ggdt/src/graphics/bitmap/rgb/triangles.rs b/ggdt/src/graphics/bitmap/rgb/triangles.rs index 0c15d13..bc0d1fe 100644 --- a/ggdt/src/graphics/bitmap/rgb/triangles.rs +++ b/ggdt/src/graphics/bitmap/rgb/triangles.rs @@ -1,26 +1,26 @@ use std::simd; -use crate::graphics::{edge_function, per_pixel_triangle_2d, ARGBu8x4, BlendFunction, RgbaBitmap}; +use crate::graphics::{edge_function, per_pixel_triangle_2d, BlendFunction, RgbaBitmap, ARGB}; use crate::math::Vector2; #[derive(Debug, Copy, Clone, PartialEq)] pub enum RgbaTriangle2d<'a> { Solid { position: [Vector2; 3], // - color: ARGBu8x4, + color: ARGB, }, SolidBlended { position: [Vector2; 3], // - color: ARGBu8x4, + color: ARGB, blend: BlendFunction, }, SolidMultiColor { position: [Vector2; 3], // - color: [ARGBu8x4; 3], + color: [ARGB; 3], }, SolidMultiColorBlended { position: [Vector2; 3], // - color: [ARGBu8x4; 3], + color: [ARGB; 3], blend: BlendFunction, }, SolidTextured { @@ -31,26 +31,26 @@ pub enum RgbaTriangle2d<'a> { SolidTexturedColored { position: [Vector2; 3], // texcoord: [Vector2; 3], - color: ARGBu8x4, + color: ARGB, bitmap: &'a RgbaBitmap, }, SolidTexturedColoredBlended { position: [Vector2; 3], // texcoord: [Vector2; 3], - color: ARGBu8x4, + color: ARGB, bitmap: &'a RgbaBitmap, blend: BlendFunction, }, SolidTexturedMultiColored { position: [Vector2; 3], // texcoord: [Vector2; 3], - color: [ARGBu8x4; 3], + color: [ARGB; 3], bitmap: &'a RgbaBitmap, }, SolidTexturedMultiColoredBlended { position: [Vector2; 3], // texcoord: [Vector2; 3], - color: [ARGBu8x4; 3], + color: [ARGB; 3], bitmap: &'a RgbaBitmap, blend: BlendFunction, }, @@ -58,7 +58,7 @@ pub enum RgbaTriangle2d<'a> { position: [Vector2; 3], // texcoord: [Vector2; 3], bitmap: &'a RgbaBitmap, - tint: ARGBu8x4, + tint: ARGB, }, SolidTexturedBlended { position: [Vector2; 3], // @@ -69,7 +69,7 @@ pub enum RgbaTriangle2d<'a> { } impl RgbaBitmap { - pub fn solid_triangle_2d(&mut self, positions: &[Vector2; 3], color: ARGBu8x4) { + pub fn solid_triangle_2d(&mut self, positions: &[Vector2; 3], color: ARGB) { per_pixel_triangle_2d( self, // positions[0], @@ -79,7 +79,7 @@ impl RgbaBitmap { ) } - pub fn solid_blended_triangle_2d(&mut self, positions: &[Vector2; 3], color: ARGBu8x4, blend: BlendFunction) { + pub fn solid_blended_triangle_2d(&mut self, positions: &[Vector2; 3], color: ARGB, blend: BlendFunction) { per_pixel_triangle_2d( self, // positions[0], @@ -89,7 +89,7 @@ impl RgbaBitmap { ) } - pub fn solid_multicolor_triangle_2d(&mut self, positions: &[Vector2; 3], colors: &[ARGBu8x4; 3]) { + pub fn solid_multicolor_triangle_2d(&mut self, positions: &[Vector2; 3], colors: &[ARGB; 3]) { let area = simd::f32x4::splat(edge_function(positions[0], positions[1], positions[2])); let color1 = colors[0].0.cast(); let color2 = colors[1].0.cast(); @@ -105,7 +105,7 @@ impl RgbaBitmap { + simd::f32x4::splat(w2) * color3) / area) .cast(); - *dest_pixels = ARGBu8x4(color) + *dest_pixels = ARGB(color) }, ) } @@ -113,7 +113,7 @@ impl RgbaBitmap { pub fn solid_multicolor_blended_triangle_2d( &mut self, positions: &[Vector2; 3], - colors: &[ARGBu8x4; 3], + colors: &[ARGB; 3], blend: BlendFunction, ) { let area = simd::f32x4::splat(edge_function(positions[0], positions[1], positions[2])); @@ -131,7 +131,7 @@ impl RgbaBitmap { + simd::f32x4::splat(w2) * color3) / area) .cast(); - *dest_pixels = blend.blend(ARGBu8x4(color), *dest_pixels) + *dest_pixels = blend.blend(ARGB(color), *dest_pixels) }, ) } @@ -160,7 +160,7 @@ impl RgbaBitmap { &mut self, positions: &[Vector2; 3], texcoords: &[Vector2; 3], - color: ARGBu8x4, + color: ARGB, bitmap: &Self, ) { let area = simd::f32x2::splat(edge_function(positions[0], positions[1], positions[2])); @@ -187,7 +187,7 @@ impl RgbaBitmap { &mut self, positions: &[Vector2; 3], texcoords: &[Vector2; 3], - color: ARGBu8x4, + color: ARGB, bitmap: &Self, blend: BlendFunction, ) { @@ -216,7 +216,7 @@ impl RgbaBitmap { &mut self, positions: &[Vector2; 3], texcoords: &[Vector2; 3], - colors: &[ARGBu8x4; 3], + colors: &[ARGB; 3], bitmap: &Self, ) { let area = simd::f32x4::splat(edge_function(positions[0], positions[1], positions[2])); @@ -241,7 +241,7 @@ impl RgbaBitmap { let color = ((w0 * color1 + w1 * color2 + w2 * color3) / area).cast::(); let texcoord = (w0 * texcoord1 + w1 * texcoord2 + w2 * texcoord3) / area; let texel = bitmap.sample_at(texcoord[0], texcoord[1]); - *dest_pixels = texel * ARGBu8x4(color) + *dest_pixels = texel * ARGB(color) }, ) } @@ -250,7 +250,7 @@ impl RgbaBitmap { &mut self, positions: &[Vector2; 3], texcoords: &[Vector2; 3], - colors: &[ARGBu8x4; 3], + colors: &[ARGB; 3], bitmap: &Self, blend: BlendFunction, ) { @@ -276,7 +276,7 @@ impl RgbaBitmap { let color = ((w0 * color1 + w1 * color2 + w2 * color3) / area).cast::(); let texcoord = (w0 * texcoord1 + w1 * texcoord2 + w2 * texcoord3) / area; let texel = bitmap.sample_at(texcoord[0], texcoord[1]); - let src = texel * ARGBu8x4(color); + let src = texel * ARGB(color); *dest_pixels = blend.blend(src, *dest_pixels) }, ) @@ -287,7 +287,7 @@ impl RgbaBitmap { positions: &[Vector2; 3], texcoords: &[Vector2; 3], bitmap: &Self, - tint: ARGBu8x4, + tint: ARGB, ) { let area = simd::f32x2::splat(edge_function(positions[0], positions[1], positions[2])); let texcoord1 = simd::f32x2::from_array([texcoords[0].x, texcoords[0].y]); diff --git a/ggdt/src/graphics/color.rs b/ggdt/src/graphics/color.rs index bb1b4c2..2db298e 100644 --- a/ggdt/src/graphics/color.rs +++ b/ggdt/src/graphics/color.rs @@ -7,30 +7,30 @@ use crate::utils::{ReadType, WriteType}; // these colours are taken from the default VGA palette -pub const COLOR_BLACK: ARGBu8x4 = ARGBu8x4::from_rgb([0, 0, 0]); -pub const COLOR_BLUE: ARGBu8x4 = ARGBu8x4::from_rgb([0, 0, 170]); -pub const COLOR_GREEN: ARGBu8x4 = ARGBu8x4::from_rgb([0, 170, 0]); -pub const COLOR_CYAN: ARGBu8x4 = ARGBu8x4::from_rgb([0, 170, 170]); -pub const COLOR_RED: ARGBu8x4 = ARGBu8x4::from_rgb([170, 0, 0]); -pub const COLOR_MAGENTA: ARGBu8x4 = ARGBu8x4::from_rgb([170, 0, 170]); -pub const COLOR_BROWN: ARGBu8x4 = ARGBu8x4::from_rgb([170, 85, 0]); -pub const COLOR_LIGHT_GRAY: ARGBu8x4 = ARGBu8x4::from_rgb([170, 170, 170]); -pub const COLOR_DARK_GRAY: ARGBu8x4 = ARGBu8x4::from_rgb([85, 85, 85]); -pub const COLOR_BRIGHT_BLUE: ARGBu8x4 = ARGBu8x4::from_rgb([85, 85, 255]); -pub const COLOR_BRIGHT_GREEN: ARGBu8x4 = ARGBu8x4::from_rgb([85, 255, 85]); -pub const COLOR_BRIGHT_CYAN: ARGBu8x4 = ARGBu8x4::from_rgb([85, 255, 255]); -pub const COLOR_BRIGHT_RED: ARGBu8x4 = ARGBu8x4::from_rgb([255, 85, 85]); -pub const COLOR_BRIGHT_MAGENTA: ARGBu8x4 = ARGBu8x4::from_rgb([255, 85, 255]); -pub const COLOR_BRIGHT_YELLOW: ARGBu8x4 = ARGBu8x4::from_rgb([255, 255, 85]); -pub const COLOR_BRIGHT_WHITE: ARGBu8x4 = ARGBu8x4::from_rgb([255, 255, 255]); +pub const COLOR_BLACK: ARGB = ARGB::from_rgb([0, 0, 0]); +pub const COLOR_BLUE: ARGB = ARGB::from_rgb([0, 0, 170]); +pub const COLOR_GREEN: ARGB = ARGB::from_rgb([0, 170, 0]); +pub const COLOR_CYAN: ARGB = ARGB::from_rgb([0, 170, 170]); +pub const COLOR_RED: ARGB = ARGB::from_rgb([170, 0, 0]); +pub const COLOR_MAGENTA: ARGB = ARGB::from_rgb([170, 0, 170]); +pub const COLOR_BROWN: ARGB = ARGB::from_rgb([170, 85, 0]); +pub const COLOR_LIGHT_GRAY: ARGB = ARGB::from_rgb([170, 170, 170]); +pub const COLOR_DARK_GRAY: ARGB = ARGB::from_rgb([85, 85, 85]); +pub const COLOR_BRIGHT_BLUE: ARGB = ARGB::from_rgb([85, 85, 255]); +pub const COLOR_BRIGHT_GREEN: ARGB = ARGB::from_rgb([85, 255, 85]); +pub const COLOR_BRIGHT_CYAN: ARGB = ARGB::from_rgb([85, 255, 255]); +pub const COLOR_BRIGHT_RED: ARGB = ARGB::from_rgb([255, 85, 85]); +pub const COLOR_BRIGHT_MAGENTA: ARGB = ARGB::from_rgb([255, 85, 255]); +pub const COLOR_BRIGHT_YELLOW: ARGB = ARGB::from_rgb([255, 255, 85]); +pub const COLOR_BRIGHT_WHITE: ARGB = ARGB::from_rgb([255, 255, 255]); // TODO: probably should name these better, after i do much more reading on the subject :-) #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum BlendFunction { Blend, BlendSourceWithAlpha(u8), - TintedBlend(ARGBu8x4), - MultipliedBlend(ARGBu8x4), + TintedBlend(ARGB), + MultipliedBlend(ARGB), } impl BlendFunction { @@ -44,7 +44,7 @@ impl BlendFunction { /// * `dest`: the destination color to blend the source color over /// /// returns: the blended color - pub fn blend(&self, src: ARGBu8x4, dest: ARGBu8x4) -> ARGBu8x4 { + pub fn blend(&self, src: ARGB, dest: ARGB) -> ARGB { use BlendFunction::*; match self { Blend => src.blend(dest), @@ -89,9 +89,9 @@ pub trait ColorsAsBytes { /// order alpha, red, green, blue. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)] #[repr(transparent)] -pub struct ARGBu8x4(pub simd::u8x4); +pub struct ARGB(pub simd::u8x4); -impl ARGBu8x4 { +impl ARGB { pub const SIZE: usize = std::mem::size_of::(); /// Returns a color value composed of the provided ARGB color components. @@ -103,7 +103,7 @@ impl ARGBu8x4 { /// returns: the composed color value #[inline] pub const fn from_argb(argb: [u8; 4]) -> Self { - ARGBu8x4(simd::u8x4::from_array(argb)) + ARGB(simd::u8x4::from_array(argb)) } /// Returns a color value composed of the provided RGB color components. Substitutes a value of 255 for the @@ -116,7 +116,7 @@ impl ARGBu8x4 { /// returns: the composed color value #[inline] pub const fn from_rgb(rgb: [u8; 3]) -> Self { - ARGBu8x4(simd::u8x4::from_array([255, rgb[0], rgb[1], rgb[2]])) + ARGB(simd::u8x4::from_array([255, rgb[0], rgb[1], rgb[2]])) } /// Returns the current alpha component value (0-255) of this color. @@ -193,7 +193,7 @@ impl ARGBu8x4 { fn blend_components(strength: u8, src: Self, dest: Self) -> Self { let strength = simd::u16x4::splat(strength as u16); let max = simd::u16x4::splat(255); - ARGBu8x4((((src.0.cast() * strength) + (dest.0.cast() * (max - strength))) / max).cast()) + ARGB((((src.0.cast() * strength) + (dest.0.cast() * (max - strength))) / max).cast()) } /// Alpha blends two colors together, using this color as the source color and the other provided color as the @@ -206,12 +206,12 @@ impl ARGBu8x4 { /// returns: the blended color result #[inline] pub fn blend(&self, dest: Self) -> Self { - ARGBu8x4::blend_components(self.a(), *self, dest) + ARGB::blend_components(self.a(), *self, dest) } /// Alpha blends two colors together, where the alpha value used to blend the colors is derived from the given /// alpha value multiplied with the source color's alpha component. This allows for more flexibility versus the - /// [`ARGBu8x4::blend`] method allowing direct control over how transparent the source color is when blended over + /// [`ARGB::blend`] method allowing direct control over how transparent the source color is when blended over /// top of the destination. The blend is performed using this color as the source color and the other provided /// color as the destination color. /// @@ -227,7 +227,7 @@ impl ARGBu8x4 { #[inline] pub fn blend_with_alpha(&self, dest: Self, alpha: u8) -> Self { let alpha = ((alpha as u16 * self.a() as u16) / 255) as u8; - let mut blended = ARGBu8x4::blend_components(alpha, *self, dest); + let mut blended = ARGB::blend_components(alpha, *self, dest); blended.set_a(alpha); blended } @@ -245,7 +245,7 @@ impl ARGBu8x4 { pub fn tint(&self, mut tint: Self) -> Self { let strength = tint.a(); tint.set_a(self.a()); - ARGBu8x4::blend_components(strength, tint, *self) + ARGB::blend_components(strength, tint, *self) } /// Linearly interpolates between this color and another color. @@ -258,7 +258,7 @@ impl ARGBu8x4 { /// returns: the interpolated color result #[inline] pub fn lerp(&self, other: Self, t: f32) -> Self { - ARGBu8x4((self.0.cast() + (other.0 - self.0).cast() * simd::f32x4::splat(t)).cast()) + ARGB((self.0.cast() + (other.0 - self.0).cast() * simd::f32x4::splat(t)).cast()) } /// Calculates this color's luminance, returned as a value between 0.0 and 1.0. @@ -277,18 +277,18 @@ impl ARGBu8x4 { } } -impl Mul for ARGBu8x4 { - type Output = ARGBu8x4; +impl Mul for ARGB { + type Output = ARGB; /// Multiplies two colors together, returning the result. The multiplication is performed by individually /// multiplying each color component using the formula `(component * component) / 255`. #[inline] fn mul(self, rhs: Self) -> Self::Output { - ARGBu8x4(((self.0.cast::() * rhs.0.cast::()) / simd::u32x4::splat(255)).cast()) + ARGB(((self.0.cast::() * rhs.0.cast::()) / simd::u32x4::splat(255)).cast()) } } -impl MulAssign for ARGBu8x4 { +impl MulAssign for ARGB { /// Multiplies two colors together, assigning the result of the multiplication to this color. The multiplication is /// performed by individually multiplying each color component using the formula `(component * component) / 255`. #[inline] @@ -297,12 +297,12 @@ impl MulAssign for ARGBu8x4 { } } -impl From for ARGBu8x4 { +impl From for ARGB { /// Returns a color value constructed by unpacking ARGB color components from the given u32 value. The u32 value /// provided is parsed assuming the following locations of each color component: 0xAARRGGBB. #[inline] fn from(value: u32) -> Self { - ARGBu8x4::from_argb([ + ARGB::from_argb([ ((value & 0xff000000) >> 24) as u8, // a ((value & 0x00ff0000) >> 16) as u8, // r ((value & 0x0000ff00) >> 8) as u8, // g @@ -311,11 +311,11 @@ impl From for ARGBu8x4 { } } -impl From for u32 { +impl From for u32 { /// Returns a u32 containing packed ARGB color components from this color. The returned u32 value contains the /// color components packed in format 0xAARRGGBB. #[inline] - fn from(value: ARGBu8x4) -> Self { + fn from(value: ARGB) -> Self { (value.b() as u32) // b + ((value.g() as u32) << 8) // g + ((value.r() as u32) << 16) // r @@ -323,11 +323,11 @@ impl From for u32 { } } -impl From for ARGBu8x4 { - /// Converts a [`ARGBf32x4`] color to an equivalent [`ARGBu8x4`] color value. +impl From for ARGB { + /// Converts a [`ARGBf`] color to an equivalent [`ARGB`] color value. #[inline] - fn from(value: ARGBf32x4) -> Self { - ARGBu8x4::from_argb([ + fn from(value: ARGBf) -> Self { + ARGB::from_argb([ (value.a() * 255.0) as u8, (value.r() * 255.0) as u8, (value.g() * 255.0) as u8, @@ -336,25 +336,25 @@ impl From for ARGBu8x4 { } } -impl BytesAsColors for [u8] { +impl BytesAsColors for [u8] { #[inline] - unsafe fn as_colors(&self) -> &[ARGBu8x4] { + unsafe fn as_colors(&self) -> &[ARGB] { std::slice::from_raw_parts( - self.as_ptr() as *const ARGBu8x4, // - self.len() / std::mem::size_of::(), + self.as_ptr() as *const ARGB, // + self.len() / std::mem::size_of::(), ) } #[inline] - unsafe fn as_colors_mut(&mut self) -> &mut [ARGBu8x4] { + unsafe fn as_colors_mut(&mut self) -> &mut [ARGB] { std::slice::from_raw_parts_mut( - self.as_mut_ptr() as *mut ARGBu8x4, // - self.len() / std::mem::size_of::(), + self.as_mut_ptr() as *mut ARGB, // + self.len() / std::mem::size_of::(), ) } } -impl ColorsAsBytes for [ARGBu8x4] { +impl ColorsAsBytes for [ARGB] { #[inline] fn as_bytes(&self) -> &[u8] { unsafe { @@ -376,19 +376,19 @@ impl ColorsAsBytes for [ARGBu8x4] { } } -impl std::fmt::Debug for ARGBu8x4 { +impl std::fmt::Debug for ARGB { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "0x{:02x}{:02x}{:02x}{:02x}", self.a(), self.r(), self.g(), self.b()) } } -impl std::fmt::Display for ARGBu8x4 { +impl std::fmt::Display for ARGB { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "0x{:02x}{:02x}{:02x}{:02x}", self.a(), self.r(), self.g(), self.b()) } } -impl WriteType for ARGBu8x4 { +impl WriteType for ARGB { type ErrorType = std::io::Error; #[inline] @@ -398,13 +398,13 @@ impl WriteType for ARGBu8x4 { } } -impl ReadType for ARGBu8x4 { +impl ReadType for ARGB { type OutputType = Self; type ErrorType = std::io::Error; #[inline] fn read(reader: &mut T) -> Result { - Ok(ARGBu8x4::from_argb([reader.read_u8()?, reader.read_u8()?, reader.read_u8()?, reader.read_u8()?])) + Ok(ARGB::from_argb([reader.read_u8()?, reader.read_u8()?, reader.read_u8()?, reader.read_u8()?])) } } @@ -412,9 +412,9 @@ impl ReadType for ARGBu8x4 { /// components are in the order alpha, red, green, blue. #[derive(Copy, Clone, PartialEq, PartialOrd, Default)] #[repr(transparent)] -pub struct ARGBf32x4(pub simd::f32x4); +pub struct ARGBf(pub simd::f32x4); -impl ARGBf32x4 { +impl ARGBf { /// Returns a color value composed of the provided ARGB color components. /// /// # Arguments @@ -424,7 +424,7 @@ impl ARGBf32x4 { /// returns: the composed color value #[inline] pub const fn from_argb(argb: [f32; 4]) -> Self { - ARGBf32x4(simd::f32x4::from_array(argb)) + ARGBf(simd::f32x4::from_array(argb)) } /// Returns a color value composed of the provided RGB color components. Substitutes a value of 1.0 for the @@ -437,7 +437,7 @@ impl ARGBf32x4 { /// returns: the composed color value #[inline] pub const fn from_rgb(rgb: [f32; 3]) -> Self { - ARGBf32x4(simd::f32x4::from_array([1.0, rgb[0], rgb[1], rgb[2]])) + ARGBf(simd::f32x4::from_array([1.0, rgb[0], rgb[1], rgb[2]])) } /// Returns the current alpha component value (0.0 to 1.0) of this color. @@ -511,12 +511,12 @@ impl ARGBf32x4 { } } -impl From for ARGBf32x4 { +impl From for ARGBf { /// Returns a color value constructed by unpacking ARGB color components from the given u32 value. The u32 value /// provided is parsed assuming the following locations of each color component: 0xAARRGGBB. #[inline] fn from(value: u32) -> Self { - ARGBf32x4::from_argb([ + ARGBf::from_argb([ ((value & 0xff000000) >> 24) as f32 / 255.0, // a ((value & 0x00ff0000) >> 16) as f32 / 255.0, // r ((value & 0x0000ff00) >> 8) as f32 / 255.0, // g @@ -525,11 +525,11 @@ impl From for ARGBf32x4 { } } -impl From for ARGBf32x4 { - /// Converts a [`ARGBf32x4`] color to an equivalent [`ARGBu8x4`] color value. +impl From for ARGBf { + /// Converts a [`ARGBf`] color to an equivalent [`ARGB`] color value. #[inline] - fn from(value: ARGBu8x4) -> Self { - ARGBf32x4::from_argb([ + fn from(value: ARGB) -> Self { + ARGBf::from_argb([ value.a() as f32 / 255.0, value.r() as f32 / 255.0, value.g() as f32 / 255.0, @@ -538,13 +538,13 @@ impl From for ARGBf32x4 { } } -impl std::fmt::Debug for ARGBf32x4 { +impl std::fmt::Debug for ARGBf { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "ARGBf32x4({}, {}, {}, {})", self.a(), self.r(), self.g(), self.b()) } } -impl std::fmt::Display for ARGBf32x4 { +impl std::fmt::Display for ARGBf { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{{A={}, R={}, G={}, B={}}}", self.a(), self.r(), self.g(), self.b()) } @@ -593,8 +593,8 @@ mod tests { use crate::math::NearlyEqual; #[test] - fn argbu8x4() { - let mut color = ARGBu8x4(simd::u8x4::from_array([0x11, 0x22, 0x33, 0x44])); + fn argb() { + let mut color = ARGB(simd::u8x4::from_array([0x11, 0x22, 0x33, 0x44])); assert_eq!(color.a(), 0x11); assert_eq!(color.r(), 0x22); assert_eq!(color.g(), 0x33); @@ -610,103 +610,94 @@ mod tests { color.set_b(0x88); assert_eq!(color.to_array(), [0x55, 0x66, 0x77, 0x88]); - let color = ARGBu8x4::from_argb([0x11, 0x22, 0x33, 0x44]); + let color = ARGB::from_argb([0x11, 0x22, 0x33, 0x44]); assert_eq!(color.to_array(), [0x11, 0x22, 0x33, 0x44]); - let color = ARGBu8x4::from_rgb([0x11, 0x22, 0x33]); + let color = ARGB::from_rgb([0x11, 0x22, 0x33]); assert_eq!(color.to_array(), [0xff, 0x11, 0x22, 0x33]); - let color: ARGBu8x4 = 0x11223344.into(); + let color: ARGB = 0x11223344.into(); assert_eq!(color.to_array(), [0x11, 0x22, 0x33, 0x44]); - let other = ARGBf32x4::from_argb([0.5, 0.1, 0.2, 0.3]); - let color: ARGBu8x4 = other.into(); + let other = ARGBf::from_argb([0.5, 0.1, 0.2, 0.3]); + let color: ARGB = other.into(); assert_eq!(color.to_array(), [0x7f, 0x19, 0x33, 0x4c]); - let color = ARGBu8x4::from_argb([0x11, 0x22, 0x33, 0x44]); + let color = ARGB::from_argb([0x11, 0x22, 0x33, 0x44]); assert_eq!(0x11223344u32, color.into()) } #[test] - fn argbu8x4_multiplication() { - assert_eq!([0xff, 0x11, 0x22, 0x33], (ARGBu8x4::from(0xffffffff) * ARGBu8x4::from(0xff112233)).to_array()); - assert_eq!([0xff, 0x11, 0x22, 0x33], (ARGBu8x4::from(0xff112233) * ARGBu8x4::from(0xffffffff)).to_array()); - assert_eq!([0x7f, 0x03, 0x00, 0x14], (ARGBu8x4::from(0x7f330066) * ARGBu8x4::from(0xff112233)).to_array()); - assert_eq!([0x7f, 0x03, 0x00, 0x14], (ARGBu8x4::from(0xff112233) * ARGBu8x4::from(0x7f330066)).to_array()); + fn argb_multiplication() { + assert_eq!([0xff, 0x11, 0x22, 0x33], (ARGB::from(0xffffffff) * ARGB::from(0xff112233)).to_array()); + assert_eq!([0xff, 0x11, 0x22, 0x33], (ARGB::from(0xff112233) * ARGB::from(0xffffffff)).to_array()); + assert_eq!([0x7f, 0x03, 0x00, 0x14], (ARGB::from(0x7f330066) * ARGB::from(0xff112233)).to_array()); + assert_eq!([0x7f, 0x03, 0x00, 0x14], (ARGB::from(0xff112233) * ARGB::from(0x7f330066)).to_array()); - let mut color = ARGBu8x4::from(0xffffffff); - color *= ARGBu8x4::from(0xff112233); + let mut color = ARGB::from(0xffffffff); + color *= ARGB::from(0xff112233); assert_eq!([0xff, 0x11, 0x22, 0x33], color.to_array()); - let mut color = ARGBu8x4::from(0xff112233); - color *= ARGBu8x4::from(0xffffffff); + let mut color = ARGB::from(0xff112233); + color *= ARGB::from(0xffffffff); assert_eq!([0xff, 0x11, 0x22, 0x33], color.to_array()); - let mut color = ARGBu8x4::from(0x7f330066); - color *= ARGBu8x4::from(0xff112233); + let mut color = ARGB::from(0x7f330066); + color *= ARGB::from(0xff112233); assert_eq!([0x7f, 0x03, 0x00, 0x14], color.to_array()); - let mut color = ARGBu8x4::from(0xff112233); - color *= ARGBu8x4::from(0x7f330066); + let mut color = ARGB::from(0xff112233); + color *= ARGB::from(0x7f330066); assert_eq!([0x7f, 0x03, 0x00, 0x14], color.to_array()); } #[test] - fn argbu8x4_lerping() { - assert_eq!( - [0x7f, 0x11, 0x22, 0x33], - (ARGBu8x4::from(0x7f112233).lerp(ARGBu8x4::from(0xffaabbcc), 0.0).to_array()) - ); - assert_eq!( - [0xbf, 0x5d, 0x6e, 0x7f], - (ARGBu8x4::from(0x7f112233).lerp(ARGBu8x4::from(0xffaabbcc), 0.5).to_array()) - ); - assert_eq!( - [0xff, 0xaa, 0xbb, 0xcc], - (ARGBu8x4::from(0x7f112233).lerp(ARGBu8x4::from(0xffaabbcc), 1.0).to_array()) - ); + fn argb_lerping() { + assert_eq!([0x7f, 0x11, 0x22, 0x33], (ARGB::from(0x7f112233).lerp(ARGB::from(0xffaabbcc), 0.0).to_array())); + assert_eq!([0xbf, 0x5d, 0x6e, 0x7f], (ARGB::from(0x7f112233).lerp(ARGB::from(0xffaabbcc), 0.5).to_array())); + assert_eq!([0xff, 0xaa, 0xbb, 0xcc], (ARGB::from(0x7f112233).lerp(ARGB::from(0xffaabbcc), 1.0).to_array())); } #[test] #[rustfmt::skip] - fn argbu8x4_blending() { + fn argb_blending() { // TODO: for .blend(), is this really the behaviour we want? the output value's alpha // is blended, but the source color's alpha is what is ultimately used to control // the blend operation. what is best here? the output RGB color looks correct at // any rate, just not sure what the proper output alpha component *should* be in // all cases. - assert_eq!([0xff, 0x11, 0x22, 0x33], ARGBu8x4::from(0xff112233).blend(ARGBu8x4::from(0xff555555)).to_array()); - assert_eq!([0xbf, 0x33, 0x3b, 0x44], ARGBu8x4::from(0x7f112233).blend(ARGBu8x4::from(0xff555555)).to_array()); - assert_eq!([0xff, 0x55, 0x55, 0x55], ARGBu8x4::from(0x00112233).blend(ARGBu8x4::from(0xff555555)).to_array()); + assert_eq!([0xff, 0x11, 0x22, 0x33], ARGB::from(0xff112233).blend(ARGB::from(0xff555555)).to_array()); + assert_eq!([0xbf, 0x33, 0x3b, 0x44], ARGB::from(0x7f112233).blend(ARGB::from(0xff555555)).to_array()); + assert_eq!([0xff, 0x55, 0x55, 0x55], ARGB::from(0x00112233).blend(ARGB::from(0xff555555)).to_array()); - assert_eq!([0xff, 0x11, 0x22, 0x33], ARGBu8x4::from(0xff112233).blend(ARGBu8x4::from(0x7f555555)).to_array()); - assert_eq!([0x7f, 0x33, 0x3b, 0x44], ARGBu8x4::from(0x7f112233).blend(ARGBu8x4::from(0x7f555555)).to_array()); - assert_eq!([0x7f, 0x55, 0x55, 0x55], ARGBu8x4::from(0x00112233).blend(ARGBu8x4::from(0x7f555555)).to_array()); + assert_eq!([0xff, 0x11, 0x22, 0x33], ARGB::from(0xff112233).blend(ARGB::from(0x7f555555)).to_array()); + assert_eq!([0x7f, 0x33, 0x3b, 0x44], ARGB::from(0x7f112233).blend(ARGB::from(0x7f555555)).to_array()); + assert_eq!([0x7f, 0x55, 0x55, 0x55], ARGB::from(0x00112233).blend(ARGB::from(0x7f555555)).to_array()); - assert_eq!([0xff, 0x11, 0x22, 0x33], ARGBu8x4::from(0xff112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 255).to_array()); - assert_eq!([0x7f, 0x33, 0x3b, 0x44], ARGBu8x4::from(0x7f112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 255).to_array()); - assert_eq!([0x00, 0x55, 0x55, 0x55], ARGBu8x4::from(0x00112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 255).to_array()); + assert_eq!([0xff, 0x11, 0x22, 0x33], ARGB::from(0xff112233).blend_with_alpha(ARGB::from(0xff555555), 255).to_array()); + assert_eq!([0x7f, 0x33, 0x3b, 0x44], ARGB::from(0x7f112233).blend_with_alpha(ARGB::from(0xff555555), 255).to_array()); + assert_eq!([0x00, 0x55, 0x55, 0x55], ARGB::from(0x00112233).blend_with_alpha(ARGB::from(0xff555555), 255).to_array()); - assert_eq!([0xff, 0x11, 0x22, 0x33], ARGBu8x4::from(0xff112233).blend_with_alpha(ARGBu8x4::from(0x7f555555), 255).to_array()); - assert_eq!([0x7f, 0x33, 0x3b, 0x44], ARGBu8x4::from(0x7f112233).blend_with_alpha(ARGBu8x4::from(0x7f555555), 255).to_array()); - assert_eq!([0x00, 0x55, 0x55, 0x55], ARGBu8x4::from(0x00112233).blend_with_alpha(ARGBu8x4::from(0x7f555555), 255).to_array()); + assert_eq!([0xff, 0x11, 0x22, 0x33], ARGB::from(0xff112233).blend_with_alpha(ARGB::from(0x7f555555), 255).to_array()); + assert_eq!([0x7f, 0x33, 0x3b, 0x44], ARGB::from(0x7f112233).blend_with_alpha(ARGB::from(0x7f555555), 255).to_array()); + assert_eq!([0x00, 0x55, 0x55, 0x55], ARGB::from(0x00112233).blend_with_alpha(ARGB::from(0x7f555555), 255).to_array()); - assert_eq!([0x80, 0x32, 0x3b, 0x43], ARGBu8x4::from(0xff112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 128).to_array()); - assert_eq!([0x3f, 0x44, 0x48, 0x4c], ARGBu8x4::from(0x7f112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 128).to_array()); - assert_eq!([0x00, 0x55, 0x55, 0x55], ARGBu8x4::from(0x00112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 128).to_array()); + assert_eq!([0x80, 0x32, 0x3b, 0x43], ARGB::from(0xff112233).blend_with_alpha(ARGB::from(0xff555555), 128).to_array()); + assert_eq!([0x3f, 0x44, 0x48, 0x4c], ARGB::from(0x7f112233).blend_with_alpha(ARGB::from(0xff555555), 128).to_array()); + assert_eq!([0x00, 0x55, 0x55, 0x55], ARGB::from(0x00112233).blend_with_alpha(ARGB::from(0xff555555), 128).to_array()); - assert_eq!([0x00, 0x55, 0x55, 0x55], ARGBu8x4::from(0xff112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 0).to_array()); - assert_eq!([0x00, 0x55, 0x55, 0x55], ARGBu8x4::from(0x7f112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 0).to_array()); - assert_eq!([0x00, 0x55, 0x55, 0x55], ARGBu8x4::from(0x00112233).blend_with_alpha(ARGBu8x4::from(0xff555555), 0).to_array()); + assert_eq!([0x00, 0x55, 0x55, 0x55], ARGB::from(0xff112233).blend_with_alpha(ARGB::from(0xff555555), 0).to_array()); + assert_eq!([0x00, 0x55, 0x55, 0x55], ARGB::from(0x7f112233).blend_with_alpha(ARGB::from(0xff555555), 0).to_array()); + assert_eq!([0x00, 0x55, 0x55, 0x55], ARGB::from(0x00112233).blend_with_alpha(ARGB::from(0xff555555), 0).to_array()); } #[test] - fn argbu8x4_tinting() { - assert_eq!([0xff, 0x11, 0x22, 0x33], ARGBu8x4::from(0xffffffff).tint(ARGBu8x4::from(0xff112233)).to_array()); - assert_eq!([0xff, 0x88, 0x90, 0x99], ARGBu8x4::from(0xffffffff).tint(ARGBu8x4::from(0x7f112233)).to_array()); - assert_eq!([0xff, 0xff, 0xff, 0xff], ARGBu8x4::from(0xffffffff).tint(ARGBu8x4::from(0x00112233)).to_array()); + fn argb_tinting() { + assert_eq!([0xff, 0x11, 0x22, 0x33], ARGB::from(0xffffffff).tint(ARGB::from(0xff112233)).to_array()); + assert_eq!([0xff, 0x88, 0x90, 0x99], ARGB::from(0xffffffff).tint(ARGB::from(0x7f112233)).to_array()); + assert_eq!([0xff, 0xff, 0xff, 0xff], ARGB::from(0xffffffff).tint(ARGB::from(0x00112233)).to_array()); } #[test] - fn argbu8x4_bytes_to_colors_casting() { + fn argb_bytes_to_colors_casting() { let mut bytes = [0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff]; @@ -714,10 +705,10 @@ mod tests { assert_eq!( colors, [ - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0xff, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0x00, 0xff]), - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0x00]), + ARGB::from_argb([0xff, 0x00, 0xff, 0x00]), + ARGB::from_argb([0xff, 0x00, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0xff]), ] ); @@ -725,10 +716,10 @@ mod tests { assert_eq!( colors, [ - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0xff, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0x00, 0xff]), - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0x00]), + ARGB::from_argb([0xff, 0x00, 0xff, 0x00]), + ARGB::from_argb([0xff, 0x00, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0xff]), ] ); @@ -741,10 +732,10 @@ mod tests { assert_eq!( colors, [ - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0xff, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0x00, 0xff]), - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0x00]), + ARGB::from_argb([0xff, 0x00, 0xff, 0x00]), + ARGB::from_argb([0xff, 0x00, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0xff]), ] ); @@ -752,21 +743,21 @@ mod tests { assert_eq!( colors, [ - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0xff, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0x00, 0xff]), - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0x00]), + ARGB::from_argb([0xff, 0x00, 0xff, 0x00]), + ARGB::from_argb([0xff, 0x00, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0xff]), ] ); } #[test] - fn argbu8x4_colors_to_bytes_casting() { + fn argb_colors_to_bytes_casting() { let mut colors = [ - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0xff, 0x00]), - ARGBu8x4::from_argb([0xff, 0x00, 0x00, 0xff]), - ARGBu8x4::from_argb([0xff, 0xff, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0x00]), + ARGB::from_argb([0xff, 0x00, 0xff, 0x00]), + ARGB::from_argb([0xff, 0x00, 0x00, 0xff]), + ARGB::from_argb([0xff, 0xff, 0x00, 0xff]), ]; let bytes = colors.as_bytes(); @@ -783,8 +774,8 @@ mod tests { } #[test] - fn argbf32x4() { - let mut color = ARGBf32x4(simd::f32x4::from_array([0.5, 0.1, 0.2, 0.3])); + fn argbf() { + let mut color = ARGBf(simd::f32x4::from_array([0.5, 0.1, 0.2, 0.3])); assert_eq!(color.a(), 0.5); assert_eq!(color.r(), 0.1); assert_eq!(color.g(), 0.2); @@ -800,20 +791,20 @@ mod tests { color.set_b(0.6); assert_eq!(color.to_array(), [1.0, 0.4, 0.5, 0.6]); - let color = ARGBf32x4::from_argb([0.5, 0.1, 0.2, 0.3]); + let color = ARGBf::from_argb([0.5, 0.1, 0.2, 0.3]); assert_eq!(color.to_array(), [0.5, 0.1, 0.2, 0.3]); - let color = ARGBf32x4::from_rgb([0.1, 0.2, 0.3]); + let color = ARGBf::from_rgb([0.1, 0.2, 0.3]); assert_eq!(color.to_array(), [1.0, 0.1, 0.2, 0.3]); - let color: ARGBf32x4 = 0x7f19334c.into(); + let color: ARGBf = 0x7f19334c.into(); assert!(color.a().nearly_equal(0.5, 0.01)); assert!(color.r().nearly_equal(0.1, 0.01)); assert!(color.g().nearly_equal(0.2, 0.01)); assert!(color.b().nearly_equal(0.3, 0.01)); - let other = ARGBu8x4::from_argb([0x7f, 0x19, 0x33, 0x4c]); - let color: ARGBf32x4 = other.into(); + let other = ARGB::from_argb([0x7f, 0x19, 0x33, 0x4c]); + let color: ARGBf = other.into(); assert!(color.a().nearly_equal(0.5, 0.01)); assert!(color.r().nearly_equal(0.1, 0.01)); assert!(color.g().nearly_equal(0.2, 0.01)); diff --git a/ggdt/src/graphics/palette.rs b/ggdt/src/graphics/palette.rs index eb5d4e0..b335268 100644 --- a/ggdt/src/graphics/palette.rs +++ b/ggdt/src/graphics/palette.rs @@ -7,7 +7,7 @@ use std::path::Path; use byteorder::{ReadBytesExt, WriteBytesExt}; use thiserror::Error; -use crate::graphics::{ARGBu8x4, IndexedBitmap}; +use crate::graphics::{IndexedBitmap, ARGB}; use crate::utils::abs_diff; const NUM_COLORS: usize = 256; @@ -29,19 +29,16 @@ fn to_6bit(value: u8) -> u8 { } // vga bios (0-63) format -fn read_palette_6bit( - reader: &mut T, - num_colors: usize, -) -> Result<[ARGBu8x4; NUM_COLORS], PaletteError> { +fn read_palette_6bit(reader: &mut T, num_colors: usize) -> Result<[ARGB; NUM_COLORS], PaletteError> { if num_colors > NUM_COLORS { return Err(PaletteError::OutOfRange(num_colors)); } - let mut colors = [ARGBu8x4::from_argb([255, 0, 0, 0]); NUM_COLORS]; + let mut colors = [ARGB::from_argb([255, 0, 0, 0]); NUM_COLORS]; for i in 0..num_colors { let r = reader.read_u8()?; let g = reader.read_u8()?; let b = reader.read_u8()?; - let color = ARGBu8x4::from_rgb([from_6bit(r), from_6bit(g), from_6bit(b)]); + let color = ARGB::from_rgb([from_6bit(r), from_6bit(g), from_6bit(b)]); colors[i] = color; } Ok(colors) @@ -49,7 +46,7 @@ fn read_palette_6bit( fn write_palette_6bit( writer: &mut T, - colors: &[ARGBu8x4; NUM_COLORS], + colors: &[ARGB; NUM_COLORS], num_colors: usize, ) -> Result<(), PaletteError> { if num_colors > NUM_COLORS { @@ -64,19 +61,16 @@ fn write_palette_6bit( } // normal (0-255) format -fn read_palette_8bit( - reader: &mut T, - num_colors: usize, -) -> Result<[ARGBu8x4; NUM_COLORS], PaletteError> { +fn read_palette_8bit(reader: &mut T, num_colors: usize) -> Result<[ARGB; NUM_COLORS], PaletteError> { if num_colors > NUM_COLORS { return Err(PaletteError::OutOfRange(num_colors)); } - let mut colors = [ARGBu8x4::from_argb([255, 0, 0, 0]); NUM_COLORS]; + let mut colors = [ARGB::from_argb([255, 0, 0, 0]); NUM_COLORS]; for i in 0..num_colors { let r = reader.read_u8()?; let g = reader.read_u8()?; let b = reader.read_u8()?; - let color = ARGBu8x4::from_rgb([r, g, b]); + let color = ARGB::from_rgb([r, g, b]); colors[i] = color; } Ok(colors) @@ -84,7 +78,7 @@ fn read_palette_8bit( fn write_palette_8bit( writer: &mut T, - colors: &[ARGBu8x4; NUM_COLORS], + colors: &[ARGB; NUM_COLORS], num_colors: usize, ) -> Result<(), PaletteError> { if num_colors > NUM_COLORS { @@ -118,18 +112,18 @@ pub enum PaletteFormat { /// colors are all stored individually as 32-bit packed values in the format 0xAARRGGBB. #[derive(Debug, Clone, Eq, PartialEq)] pub struct Palette { - colors: [ARGBu8x4; NUM_COLORS], + colors: [ARGB; NUM_COLORS], } impl Palette { /// Creates a new Palette with all black colors. pub fn new() -> Palette { - Palette { colors: [ARGBu8x4::from_rgb([0, 0, 0]); NUM_COLORS] } + Palette { colors: [ARGB::from_rgb([0, 0, 0]); NUM_COLORS] } } /// Creates a new Palette with all initial colors having the RGB values specified. pub fn new_with_default(r: u8, g: u8, b: u8) -> Palette { - Palette { colors: [ARGBu8x4::from_rgb([r, g, b]); NUM_COLORS] } + Palette { colors: [ARGB::from_rgb([r, g, b]); NUM_COLORS] } } /// Creates a new Palette, pre-loaded with the default VGA BIOS colors. @@ -333,7 +327,7 @@ impl Palette { } if modified { - self.colors[color as usize] = ARGBu8x4::from_rgb([r, g, b]); + self.colors[color as usize] = ARGB::from_rgb([r, g, b]); } (target_r == r) && (target_g == g) && (target_b == b) @@ -478,7 +472,7 @@ impl Palette { } impl Index for Palette { - type Output = ARGBu8x4; + type Output = ARGB; #[inline] fn index(&self, index: u8) -> &Self::Output { @@ -512,11 +506,11 @@ mod tests { #[test] fn get_and_set_colors() { let mut palette = Palette::new(); - assert_eq!(ARGBu8x4::from_rgb([0, 0, 0]), palette[0]); - assert_eq!(ARGBu8x4::from_rgb([0, 0, 0]), palette[1]); + assert_eq!(ARGB::from_rgb([0, 0, 0]), palette[0]); + assert_eq!(ARGB::from_rgb([0, 0, 0]), palette[1]); palette[0] = 0x11223344.into(); - assert_eq!(ARGBu8x4::from(0x11223344), palette[0]); - assert_eq!(ARGBu8x4::from_rgb([0, 0, 0]), palette[1]); + assert_eq!(ARGB::from(0x11223344), palette[0]); + assert_eq!(ARGB::from_rgb([0, 0, 0]), palette[1]); } fn assert_ega_colors(palette: &Palette) { diff --git a/ggdt/src/lib.rs b/ggdt/src/lib.rs index 2b0fe63..3e64fcf 100644 --- a/ggdt/src/lib.rs +++ b/ggdt/src/lib.rs @@ -21,7 +21,7 @@ mod tests { use std::io::{BufReader, Read}; use std::path::{Path, PathBuf}; - use crate::graphics::ARGBu8x4; + use crate::graphics::ARGB; use crate::utils::ReadType; #[allow(dead_code)] @@ -46,12 +46,12 @@ mod tests { Ok(buffer.into_boxed_slice()) } - pub fn load_raw_argb(bin_file: &Path) -> Result, io::Error> { + pub fn load_raw_argb(bin_file: &Path) -> Result, io::Error> { let f = File::open(bin_file)?; let mut reader = BufReader::new(f); let mut buffer = Vec::new(); loop { - buffer.push(match ARGBu8x4::read(&mut reader) { + buffer.push(match ARGB::read(&mut reader) { Ok(value) => value, Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => break, Err(err) => return Err(err), diff --git a/ggdt/src/system/framebuffer.rs b/ggdt/src/system/framebuffer.rs index 69fec86..9851df6 100644 --- a/ggdt/src/system/framebuffer.rs +++ b/ggdt/src/system/framebuffer.rs @@ -1,6 +1,6 @@ use thiserror::Error; -use crate::graphics::{ARGBu8x4, ColorsAsBytes, IndexedBitmap, Palette, RgbaBitmap}; +use crate::graphics::{ColorsAsBytes, IndexedBitmap, Palette, RgbaBitmap, ARGB}; pub fn calculate_logical_screen_size(window_width: u32, window_height: u32, scale_factor: u32) -> (u32, u32) { let logical_width = (window_width as f32 / scale_factor as f32).ceil() as u32; @@ -23,7 +23,7 @@ pub enum SdlFramebufferError { pub struct SdlFramebuffer { sdl_texture: sdl2::render::Texture, sdl_texture_pitch: usize, - intermediate_texture: Option>, + intermediate_texture: Option>, } // TODO: i'm not totally happy with this implementation. i don't like the two display methods and how the caller @@ -60,7 +60,7 @@ impl SdlFramebuffer { // bitmaps, not 32-bit RGBA pixels, so this temporary buffer is where we convert the final // application framebuffer to 32-bit RGBA pixels before it is uploaded to the SDL texture let texture_pixels_size = (logical_screen_width * logical_screen_height) as usize; - Some(vec![ARGBu8x4::default(); texture_pixels_size].into_boxed_slice()) + Some(vec![ARGB::default(); texture_pixels_size].into_boxed_slice()) } else { None }; diff --git a/ggdt/src/system/input_devices/mouse/cursor.rs b/ggdt/src/system/input_devices/mouse/cursor.rs index f5ce259..2124aa2 100644 --- a/ggdt/src/system/input_devices/mouse/cursor.rs +++ b/ggdt/src/system/input_devices/mouse/cursor.rs @@ -1,4 +1,4 @@ -use crate::graphics::{ARGBu8x4, ColorsAsBytes, GeneralBitmap, GeneralBlitMethod, IndexedBitmap, RgbaBitmap}; +use crate::graphics::{ColorsAsBytes, GeneralBitmap, GeneralBlitMethod, IndexedBitmap, RgbaBitmap, ARGB}; use crate::math::Rect; use crate::system::Mouse; @@ -267,7 +267,7 @@ impl DefaultMouseCursorBitmaps for CustomMouseCursor { cursor, hotspot_x: DEFAULT_MOUSE_CURSOR_HOTSPOT_X, hotspot_y: DEFAULT_MOUSE_CURSOR_HOTSPOT_Y, - transparent_color: ARGBu8x4::from(0xffff00ff), + transparent_color: ARGB::from(0xffff00ff), } } } diff --git a/ggdt/tests/graphics_rgba.rs b/ggdt/tests/graphics_rgba.rs index 47fcdba..c73b9ef 100644 --- a/ggdt/tests/graphics_rgba.rs +++ b/ggdt/tests/graphics_rgba.rs @@ -5,24 +5,24 @@ use helpers::test_assets_file; pub mod helpers; -const LIGHTER_BACKGROUND: ARGBu8x4 = ARGBu8x4::from_rgb([0x2c, 0x30, 0x41]); +const LIGHTER_BACKGROUND: ARGB = ARGB::from_rgb([0x2c, 0x30, 0x41]); -pub const COLOR_BLACK_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x00, 0x00, 0x00]); -pub const COLOR_BLUE_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x00, 0x00, 0xaa]); -pub const COLOR_GREEN_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x00, 0xaa, 0x00]); -pub const COLOR_CYAN_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x00, 0xaa, 0xaa]); -pub const COLOR_RED_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xaa, 0x00, 0x00]); -pub const COLOR_MAGENTA_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xaa, 0x00, 0xaa]); -pub const COLOR_BROWN_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xaa, 0x55, 0x00]); -pub const COLOR_LIGHT_GRAY_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xaa, 0xaa, 0xaa]); -pub const COLOR_DARK_GRAY_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x55, 0x55, 0x55]); -pub const COLOR_BRIGHT_BLUE_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x55, 0x55, 0xff]); -pub const COLOR_BRIGHT_GREEN_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x55, 0xff, 0x55]); -pub const COLOR_BRIGHT_CYAN_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0x55, 0xff, 0xff]); -pub const COLOR_BRIGHT_RED_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xff, 0x55, 0x55]); -pub const COLOR_BRIGHT_MAGENTA_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xff, 0x55, 0xff]); -pub const COLOR_BRIGHT_YELLOW_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xff, 0xff, 0x55]); -pub const COLOR_BRIGHT_WHITE_HALF_ALPHA: ARGBu8x4 = ARGBu8x4::from_argb([0x7f, 0xff, 0xff, 0xff]); +pub const COLOR_BLACK_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x00, 0x00, 0x00]); +pub const COLOR_BLUE_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x00, 0x00, 0xaa]); +pub const COLOR_GREEN_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x00, 0xaa, 0x00]); +pub const COLOR_CYAN_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x00, 0xaa, 0xaa]); +pub const COLOR_RED_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xaa, 0x00, 0x00]); +pub const COLOR_MAGENTA_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xaa, 0x00, 0xaa]); +pub const COLOR_BROWN_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xaa, 0x55, 0x00]); +pub const COLOR_LIGHT_GRAY_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xaa, 0xaa, 0xaa]); +pub const COLOR_DARK_GRAY_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x55, 0x55, 0x55]); +pub const COLOR_BRIGHT_BLUE_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x55, 0x55, 0xff]); +pub const COLOR_BRIGHT_GREEN_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x55, 0xff, 0x55]); +pub const COLOR_BRIGHT_CYAN_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0x55, 0xff, 0xff]); +pub const COLOR_BRIGHT_RED_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xff, 0x55, 0x55]); +pub const COLOR_BRIGHT_MAGENTA_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xff, 0x55, 0xff]); +pub const COLOR_BRIGHT_YELLOW_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xff, 0xff, 0x55]); +pub const COLOR_BRIGHT_WHITE_HALF_ALPHA: ARGB = ARGB::from_argb([0x7f, 0xff, 0xff, 0xff]); const SCREEN_WIDTH: u32 = 320; const SCREEN_HEIGHT: u32 = 240; @@ -83,7 +83,7 @@ fn pixel_addressing() { let mut i = 0; for _y in 0..16 { for _x in 0..16 { - *pixels = ARGBu8x4::from_rgb([i, i, i]); + *pixels = ARGB::from_rgb([i, i, i]); i = i.wrapping_add(1); pixels = pixels.offset(1); } @@ -636,10 +636,10 @@ fn generate_bitmap_with_varied_alpha(width: i32, height: i32) -> RgbaBitmap { let mut bitmap = RgbaBitmap::new(width as u32, height as u32).unwrap(); bitmap.clear(0.into()); // alpha=0 - let color1 = ARGBu8x4::from_argb([0x33, 0x00, 0x00, 0xaa]); - let color2 = ARGBu8x4::from_argb([0x66, 0x00, 0xaa, 0x00]); - let color3 = ARGBu8x4::from_argb([0x99, 0x00, 0xaa, 0xaa]); - let color4 = ARGBu8x4::from_argb([0xcc, 0xaa, 0x00, 0x00]); + let color1 = ARGB::from_argb([0x33, 0x00, 0x00, 0xaa]); + let color2 = ARGB::from_argb([0x66, 0x00, 0xaa, 0x00]); + let color3 = ARGB::from_argb([0x99, 0x00, 0xaa, 0xaa]); + let color4 = ARGB::from_argb([0xcc, 0xaa, 0x00, 0x00]); bitmap.filled_rect(0, 0, x_third, y_third, color1); bitmap.filled_rect(x_third * 2 + 1, y_third * 2 + 1, width - 1, height - 1, color2); @@ -656,12 +656,12 @@ fn generate_solid_bitmap_with_varied_alpha(width: i32, height: i32) -> RgbaBitma let y_third = height / 3; let mut bitmap = RgbaBitmap::new(width as u32, height as u32).unwrap(); - bitmap.clear(ARGBu8x4::from_argb([255, 0, 0, 0])); + bitmap.clear(ARGB::from_argb([255, 0, 0, 0])); - let color1 = ARGBu8x4::from_argb([0x33, 0x00, 0x00, 0xaa]); - let color2 = ARGBu8x4::from_argb([0x66, 0x00, 0xaa, 0x00]); - let color3 = ARGBu8x4::from_argb([0x99, 0x00, 0xaa, 0xaa]); - let color4 = ARGBu8x4::from_argb([0xcc, 0xaa, 0x00, 0x00]); + let color1 = ARGB::from_argb([0x33, 0x00, 0x00, 0xaa]); + let color2 = ARGB::from_argb([0x66, 0x00, 0xaa, 0x00]); + let color3 = ARGB::from_argb([0x99, 0x00, 0xaa, 0xaa]); + let color4 = ARGB::from_argb([0xcc, 0xaa, 0x00, 0x00]); bitmap.filled_rect(0, 0, x_third, y_third, color1); bitmap.filled_rect(x_third * 2 + 1, y_third * 2 + 1, width - 1, height - 1, color2); @@ -756,7 +756,7 @@ fn solid_tinted_blits() { let bmp21 = generate_bitmap(21, 21); let bmp3 = generate_bitmap(3, 3); - let method = SolidTinted(ARGBu8x4::from_argb([127, 155, 242, 21])); + let method = SolidTinted(ARGB::from_argb([127, 155, 242, 21])); let x = 40; let y = 20; @@ -961,7 +961,7 @@ fn solid_flipped_tinted_blits() { let bmp = generate_bitmap(16, 16); - let tint_color = ARGBu8x4::from_argb([127, 155, 242, 21]); + let tint_color = ARGB::from_argb([127, 155, 242, 21]); let x = 40; let y = 20; @@ -1100,7 +1100,7 @@ fn transparent_blits() { let bmp21 = generate_bitmap(21, 21); let bmp3 = generate_bitmap(3, 3); - let method = Transparent(ARGBu8x4::from_rgb([0, 0, 0])); + let method = Transparent(ARGB::from_rgb([0, 0, 0])); let x = 40; let y = 20; @@ -1172,8 +1172,8 @@ fn transparent_tinted_blits() { let bmp3 = generate_bitmap(3, 3); let method = TransparentTinted { - transparent_color: ARGBu8x4::from_rgb([0, 0, 0]), - tint_color: ARGBu8x4::from_argb([127, 155, 242, 21]), + transparent_color: ARGB::from_rgb([0, 0, 0]), + tint_color: ARGB::from_argb([127, 155, 242, 21]), }; let x = 40; @@ -1244,8 +1244,7 @@ fn blended_transparent_blits() { let bmp21 = generate_solid_bitmap_with_varied_alpha(21, 21); let bmp3 = generate_solid_bitmap_with_varied_alpha(3, 3); - let method = - TransparentBlended { transparent_color: ARGBu8x4::from_argb([255, 0, 0, 0]), blend: BlendFunction::Blend }; + let method = TransparentBlended { transparent_color: ARGB::from_argb([255, 0, 0, 0]), blend: BlendFunction::Blend }; let x = 40; let y = 20; @@ -1312,7 +1311,7 @@ fn transparent_flipped_blits() { let mut screen = setup(); screen.clear(LIGHTER_BACKGROUND); - let transparent_color = ARGBu8x4::from_rgb([0, 0, 0]); + let transparent_color = ARGB::from_rgb([0, 0, 0]); let bmp = generate_bitmap(16, 16); @@ -1381,8 +1380,8 @@ fn transparent_flipped_tinted_blits() { let mut screen = setup(); screen.clear(LIGHTER_BACKGROUND); - let transparent_color = ARGBu8x4::from_rgb([0, 0, 0]); - let tint_color = ARGBu8x4::from_argb([127, 155, 242, 21]); + let transparent_color = ARGB::from_rgb([0, 0, 0]); + let tint_color = ARGB::from_argb([127, 155, 242, 21]); let bmp = generate_bitmap(16, 16); @@ -1452,7 +1451,7 @@ fn blended_transparent_flipped_blits() { let bmp = generate_solid_bitmap_with_varied_alpha(16, 16); - let transparent_color = ARGBu8x4::from_argb([255, 0, 0, 0]); + let transparent_color = ARGB::from_argb([255, 0, 0, 0]); let blend = BlendFunction::Blend; let x = 40; @@ -1520,7 +1519,7 @@ fn transparent_single_blits() { let mut screen = setup(); screen.clear(LIGHTER_BACKGROUND); - let transparent_color = ARGBu8x4::from_rgb([0, 0, 0]); + let transparent_color = ARGB::from_rgb([0, 0, 0]); let bmp = generate_bitmap(16, 16); @@ -1593,7 +1592,7 @@ fn transparent_flipped_single_blits() { let mut screen = setup(); screen.clear(LIGHTER_BACKGROUND); - let transparent_color = ARGBu8x4::from_rgb([0, 0, 0]); + let transparent_color = ARGB::from_rgb([0, 0, 0]); let bmp = generate_bitmap(16, 16); @@ -1732,7 +1731,7 @@ fn rotozoom_tinted_blits() { let bmp = generate_bitmap(16, 16); - let tint_color = ARGBu8x4::from_argb([127, 155, 242, 21]); + let tint_color = ARGB::from_argb([127, 155, 242, 21]); let x = 40; let y = 20; @@ -1870,7 +1869,7 @@ fn rotozoom_transparent_blits() { let mut screen = setup(); screen.clear(LIGHTER_BACKGROUND); - let transparent_color = ARGBu8x4::from_rgb([0, 0, 0]); + let transparent_color = ARGB::from_rgb([0, 0, 0]); let bmp = generate_bitmap(16, 16); @@ -1941,8 +1940,8 @@ fn rotozoom_transparent_tinted_blits() { let mut screen = setup(); screen.clear(LIGHTER_BACKGROUND); - let transparent_color = ARGBu8x4::from_rgb([0, 0, 0]); - let tint_color = ARGBu8x4::from_argb([127, 155, 242, 21]); + let transparent_color = ARGB::from_rgb([0, 0, 0]); + let tint_color = ARGB::from_argb([127, 155, 242, 21]); let bmp = generate_bitmap(16, 16); @@ -2014,7 +2013,7 @@ fn blended_rotozoom_transparent_blits() { let bmp = generate_solid_bitmap_with_varied_alpha(16, 16); - let transparent_color = ARGBu8x4::from_argb([255, 0, 0, 0]); + let transparent_color = ARGB::from_argb([255, 0, 0, 0]); let blend = BlendFunction::Blend; let x = 40; @@ -2111,34 +2110,34 @@ fn blend_function_tinted_blend() { let bmp_solid_with_varied_alpha = generate_solid_bitmap_with_varied_alpha(32, 32); let bmp_with_varied_alpha = generate_bitmap_with_varied_alpha(32, 32); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGBu8x4::from_argb([255, 155, 242, 21]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGB::from_argb([255, 155, 242, 21]))); screen.blit(method.clone(), &bmp_solid, 10, 5); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 5); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 5); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGBu8x4::from_argb([127, 155, 242, 21]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGB::from_argb([127, 155, 242, 21]))); screen.blit(method.clone(), &bmp_solid, 10, 40); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 40); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 40); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGBu8x4::from_argb([0, 155, 242, 21]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGB::from_argb([0, 155, 242, 21]))); screen.blit(method.clone(), &bmp_solid, 10, 75); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 75); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 75); ////// - let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGBu8x4::from_argb([255, 155, 242, 21]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGB::from_argb([255, 155, 242, 21]))); screen.blit(method.clone(), &bmp_solid, 10, 125); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 125); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 125); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGBu8x4::from_argb([127, 155, 242, 21]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGB::from_argb([127, 155, 242, 21]))); screen.blit(method.clone(), &bmp_solid, 10, 160); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 160); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 160); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGBu8x4::from_argb([0, 155, 242, 21]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::TintedBlend(ARGB::from_argb([0, 155, 242, 21]))); screen.blit(method.clone(), &bmp_solid, 10, 195); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 195); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 195); @@ -2205,34 +2204,34 @@ fn blend_function_multiplied_blend() { let bmp_solid_with_varied_alpha = generate_solid_bitmap_with_varied_alpha(32, 32); let bmp_with_varied_alpha = generate_bitmap_with_varied_alpha(32, 32); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGBu8x4::from_argb([255, 242, 29, 81]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGB::from_argb([255, 242, 29, 81]))); screen.blit(method.clone(), &bmp_solid, 10, 5); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 5); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 5); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGBu8x4::from_argb([127, 242, 29, 81]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGB::from_argb([127, 242, 29, 81]))); screen.blit(method.clone(), &bmp_solid, 10, 40); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 40); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 40); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGBu8x4::from_argb([0, 242, 29, 81]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGB::from_argb([0, 242, 29, 81]))); screen.blit(method.clone(), &bmp_solid, 10, 75); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 75); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 75); ////// - let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGBu8x4::from_argb([255, 242, 29, 81]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGB::from_argb([255, 242, 29, 81]))); screen.blit(method.clone(), &bmp_solid, 10, 125); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 125); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 125); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGBu8x4::from_argb([127, 242, 29, 81]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGB::from_argb([127, 242, 29, 81]))); screen.blit(method.clone(), &bmp_solid, 10, 160); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 160); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 160); - let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGBu8x4::from_argb([0, 242, 29, 81]))); + let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(ARGB::from_argb([0, 242, 29, 81]))); screen.blit(method.clone(), &bmp_solid, 10, 195); screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 195); screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 195); @@ -2491,16 +2490,15 @@ fn get_quad( let positions_2 = [top_left, bottom_right, top_right]; let texcoords_1 = [Vector2::new(0.0, 0.0), Vector2::new(0.0, 1.0), Vector2::new(1.0, 1.0)]; let texcoords_2 = [Vector2::new(0.0, 0.0), Vector2::new(1.0, 1.0), Vector2::new(1.0, 0.0)]; - let single_color = ARGBu8x4::from_argb([128, 255, 0, 255]); - let colors_1 = [ARGBu8x4::from_rgb([255, 0, 0]), ARGBu8x4::from_rgb([0, 255, 0]), ARGBu8x4::from_rgb([0, 0, 255])]; - let colors_2 = - [ARGBu8x4::from_rgb([255, 0, 0]), ARGBu8x4::from_rgb([0, 0, 255]), ARGBu8x4::from_rgb([255, 255, 255])]; - let tint_color = ARGBu8x4::from_argb([128, 192, 47, 160]); + let single_color = ARGB::from_argb([128, 255, 0, 255]); + let colors_1 = [ARGB::from_rgb([255, 0, 0]), ARGB::from_rgb([0, 255, 0]), ARGB::from_rgb([0, 0, 255])]; + let colors_2 = [ARGB::from_rgb([255, 0, 0]), ARGB::from_rgb([0, 0, 255]), ARGB::from_rgb([255, 255, 255])]; + let tint_color = ARGB::from_argb([128, 192, 47, 160]); match mode { TriangleType::Solid => [ - RgbaTriangle2d::Solid { position: positions_1, color: ARGBu8x4::from_rgb([255, 0, 255]) }, - RgbaTriangle2d::Solid { position: positions_2, color: ARGBu8x4::from_rgb([255, 0, 255]) }, + RgbaTriangle2d::Solid { position: positions_1, color: ARGB::from_rgb([255, 0, 255]) }, + RgbaTriangle2d::Solid { position: positions_2, color: ARGB::from_rgb([255, 0, 255]) }, ], TriangleType::SolidBlended => [ RgbaTriangle2d::SolidBlended { position: positions_1, color: single_color, blend: BlendFunction::Blend }, diff --git a/ggdt/tests/manual/main.rs b/ggdt/tests/manual/main.rs index 707278f..7f82bd3 100644 --- a/ggdt/tests/manual/main.rs +++ b/ggdt/tests/manual/main.rs @@ -22,7 +22,7 @@ mod system_resources_standard; use ggdt::prelude::*; -const BACKGROUND_COLOR: ARGBu8x4 = ARGBu8x4::from_rgb([0x2c, 0x30, 0x41]); +const BACKGROUND_COLOR: ARGB = ARGB::from_rgb([0x2c, 0x30, 0x41]); fn draw_base_screen( dest: &mut BitmapType, diff --git a/ggdt/tests/manual/system_resources_standard.rs b/ggdt/tests/manual/system_resources_standard.rs index e0a03da..3519a16 100644 --- a/ggdt/tests/manual/system_resources_standard.rs +++ b/ggdt/tests/manual/system_resources_standard.rs @@ -27,8 +27,8 @@ fn simple_main_loop(mut system: System) { draw_base_screen( &mut system.res.video, - ARGBu8x4::from_rgb([32, 32, 32]), - ARGBu8x4::from_rgb([44, 44, 44]), + ARGB::from_rgb([32, 32, 32]), + ARGB::from_rgb([44, 44, 44]), COLOR_BRIGHT_WHITE, COLOR_BRIGHT_RED, ); diff --git a/ggdt_imgui/src/renderer.rs b/ggdt_imgui/src/renderer.rs index 0e21b2c..11b1fee 100644 --- a/ggdt_imgui/src/renderer.rs +++ b/ggdt_imgui/src/renderer.rs @@ -1,4 +1,4 @@ -use ggdt::graphics::{ARGBu8x4, BlendFunction, RgbaBitmap, RgbaPixelFormat}; +use ggdt::graphics::{BlendFunction, RgbaBitmap, RgbaPixelFormat, ARGB}; use ggdt::math::{Rect, Vector2}; use imgui::internal::RawWrapper; @@ -67,9 +67,9 @@ impl Renderer { Vector2::new(v3.uv[0], v3.uv[1]), ], &[ - ARGBu8x4::from_argb([v2.col[3], v2.col[0], v2.col[1], v2.col[2]]), - ARGBu8x4::from_argb([v1.col[3], v1.col[0], v1.col[1], v1.col[2]]), - ARGBu8x4::from_argb([v3.col[3], v3.col[0], v3.col[1], v3.col[2]]), + ARGB::from_argb([v2.col[3], v2.col[0], v2.col[1], v2.col[2]]), + ARGB::from_argb([v1.col[3], v1.col[0], v1.col[1], v1.col[2]]), + ARGB::from_argb([v3.col[3], v3.col[0], v3.col[1], v3.col[2]]), ], bitmap, BlendFunction::Blend,