Vector int-float conversion methods

This commit is contained in:
2026-01-06 21:14:12 +01:00
parent 7963813034
commit 34f0b1fb89
13 changed files with 53 additions and 5 deletions

View File

@@ -64,25 +64,25 @@ pub const Color = extern struct {
}
test l {
const i: Color = .l("#012");
const i = Color.l("#012");
try std.testing.expectEqual(0x00, i.r);
try std.testing.expectEqual(0x11, i.g);
try std.testing.expectEqual(0x22, i.b);
try std.testing.expectEqual(0xFF, i.a);
const j: Color = .l("#3456");
const j = Color.l("#3456");
try std.testing.expectEqual(0x33, j.r);
try std.testing.expectEqual(0x44, j.g);
try std.testing.expectEqual(0x55, j.b);
try std.testing.expectEqual(0x66, j.a);
const k: Color = .l("#F08040");
const k = Color.l("#F08040");
try std.testing.expectEqual(0xF0, k.r);
try std.testing.expectEqual(0x80, k.g);
try std.testing.expectEqual(0x40, k.b);
try std.testing.expectEqual(0xFF, k.a);
const m: Color = .l("#20304050");
const m = Color.l("#20304050");
try std.testing.expectEqual(0x20, m.r);
try std.testing.expectEqual(0x30, m.g);
try std.testing.expectEqual(0x40, m.b);