refactor(gui): move RGBA to color module

This commit is contained in:
CJ van den Berg 2026-04-10 12:17:47 +02:00
parent 76ed87f87b
commit 347ce61f5d
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
8 changed files with 109 additions and 67 deletions

View file

@ -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);
}