refactor(gui): move RGBA to color module
This commit is contained in:
parent
76ed87f87b
commit
347ce61f5d
8 changed files with 109 additions and 67 deletions
|
|
@ -2,6 +2,7 @@ const std = @import("std");
|
|||
const color = @import("color");
|
||||
|
||||
const RGB = color.RGB;
|
||||
const RGBA = color.RGBA;
|
||||
const rgb = RGB.from_u24;
|
||||
|
||||
test "contrast white/yellow" {
|
||||
|
|
@ -41,3 +42,19 @@ test "best contrast black/white to blue" {
|
|||
const best = color.max_contrast(0x0000FF, 0xFFFFFF, 0x000000);
|
||||
try std.testing.expectEqual(best, 0xFFFFFF);
|
||||
}
|
||||
|
||||
test "verify RGBA byte order" {
|
||||
const v1: RGBA = .init(0xA, 0xB, 0xC, 0xD);
|
||||
const v1_u32: u32 = @bitCast(v1);
|
||||
const v2: RGBA = .{
|
||||
.r = @truncate(v1_u32 >> 24),
|
||||
.g = @truncate(v1_u32 >> 16),
|
||||
.b = @truncate(v1_u32 >> 8),
|
||||
.a = @truncate(v1_u32),
|
||||
};
|
||||
const v3: RGBA = @bitCast(v1_u32);
|
||||
|
||||
const testing = @import("std").testing;
|
||||
try testing.expectEqual(v1, v2);
|
||||
try testing.expectEqual(v1, v3);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue