authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-22 03:26:47 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-22 03:26:47 -07:00
log14e9e3945fb550b52f98f7aae667b7609c5c63f5
tree938adaae5611f9dd5e6615e334f59e5f42c0b82b
parent43b07dfd9ec20389b203efaa03ed6419abecb93c
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

eliminate usingnamespace


6 files changed, 24 insertions(+), 6 deletions(-)

HSL.zig+4-1
......@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {
2727 return x.h == y.h and x.s == y.s and x.l == y.l and x.a == y.a;
2828}
2929
30pub usingnamespace _x.mixin(@This(), f32, .h, .s, .l);
30const M = _x.mixin(@This(), f32, .h, .s, .l);
31pub const to_vec = M.to_vec;
32pub const from_vec = M.from_vec;
33pub const to_array = M.to_array;
3134
3235// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB
3336// https://www.rapidtables.com/convert/color/hsl-to-rgb.html
HSV.zig+4-1
......@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {
2727 return x.h == y.h and x.s == y.s and x.v == y.v and x.a == y.a;
2828}
2929
30pub usingnamespace _x.mixin(@This(), f32, .h, .s, .v);
30const M = _x.mixin(@This(), f32, .h, .s, .v);
31pub const to_vec = M.to_vec;
32pub const from_vec = M.from_vec;
33pub const to_array = M.to_array;
3134
3235// https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB
3336// https://www.rapidtables.com/convert/color/hsv-to-rgb.html
LinearRgb.zig+4-1
......@@ -34,7 +34,10 @@ pub fn relative_luminance(x: Self) f32 {
3434 return (0.2126 * r) + (0.7152 * g) + (0.0722 * b);
3535}
3636
37pub usingnamespace _x.mixin(@This(), f32, .r, .g, .b);
37const M = _x.mixin(@This(), f32, .r, .g, .b);
38pub const to_vec = M.to_vec;
39pub const from_vec = M.from_vec;
40pub const to_array = M.to_array;
3841
3942// https://gamedev.stackexchange.com/a/194038
4043pub fn to_srgb(x: Self) color.sRGB {
YCbCr.zig+4-1
......@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {
2727 return x.y == y.y and x.cb == y.cb and x.cr == y.cr and x.a == y.a;
2828}
2929
30pub usingnamespace _x.mixin(@This(), u8, .y, .cb, .cr);
30const M = _x.mixin(@This(), u8, .y, .cb, .cr);
31pub const to_vec = M.to_vec;
32pub const from_vec = M.from_vec;
33pub const to_array = M.to_array;
3134
3235pub fn to_srgb(x: Self) color.sRGB {
3336 // zig fmt: off
YUV.zig+4-1
......@@ -26,7 +26,10 @@ pub fn eql(x: Self, y: Self) bool {
2626 return x.y == y.y and x.u == y.u and x.v == y.v and x.a == y.a;
2727}
2828
29pub usingnamespace _x.mixin(@This(), f32, .y, .u, .v);
29pub const M = _x.mixin(@This(), f32, .y, .u, .v);
30pub const to_vec = M.to_vec;
31pub const from_vec = M.from_vec;
32pub const to_array = M.to_array;
3033
3134// https://web.archive.org/web/20180423091842/http://www.equasys.de/colorconversion.html
3235pub fn to_srgb(x: Self) color.sRGB {
sRGB.zig+4-1
......@@ -67,7 +67,10 @@ pub fn format(x: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions,
6767 });
6868}
6969
70pub usingnamespace _x.mixin(@This(), u8, .r, .g, .b);
70const M = _x.mixin(@This(), u8, .r, .g, .b);
71pub const to_vec = M.to_vec;
72pub const from_vec = M.from_vec;
73pub const to_array = M.to_array;
7174
7275// https://www.w3.org/TR/WCAG/#dfn-relative-luminance
7376// https://webstore.iec.ch/publication/6169