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 {...@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {
27 return x.h == y.h and x.s == y.s and x.l == y.l and x.a == y.a;27 return x.h == y.h and x.s == y.s and x.l == y.l and x.a == y.a;
28}28}
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
32// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB35// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB
33// https://www.rapidtables.com/convert/color/hsl-to-rgb.html36// 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 {...@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {
27 return x.h == y.h and x.s == y.s and x.v == y.v and x.a == y.a;27 return x.h == y.h and x.s == y.s and x.v == y.v and x.a == y.a;
28}28}
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
32// https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB35// https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB
33// https://www.rapidtables.com/convert/color/hsv-to-rgb.html36// 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 {...@@ -34,7 +34,10 @@ pub fn relative_luminance(x: Self) f32 {
34 return (0.2126 * r) + (0.7152 * g) + (0.0722 * b);34 return (0.2126 * r) + (0.7152 * g) + (0.0722 * b);
35}35}
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
39// https://gamedev.stackexchange.com/a/19403842// https://gamedev.stackexchange.com/a/194038
40pub fn to_srgb(x: Self) color.sRGB {43pub fn to_srgb(x: Self) color.sRGB {
YCbCr.zig+4-1
...@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {...@@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool {
27 return x.y == y.y and x.cb == y.cb and x.cr == y.cr and x.a == y.a;27 return x.y == y.y and x.cb == y.cb and x.cr == y.cr and x.a == y.a;
28}28}
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
32pub fn to_srgb(x: Self) color.sRGB {35pub fn to_srgb(x: Self) color.sRGB {
33 // zig fmt: off36 // zig fmt: off
YUV.zig+4-1
...@@ -26,7 +26,10 @@ pub fn eql(x: Self, y: Self) bool {...@@ -26,7 +26,10 @@ pub fn eql(x: Self, y: Self) bool {
26 return x.y == y.y and x.u == y.u and x.v == y.v and x.a == y.a;26 return x.y == y.y and x.u == y.u and x.v == y.v and x.a == y.a;
27}27}
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
31// https://web.archive.org/web/20180423091842/http://www.equasys.de/colorconversion.html34// https://web.archive.org/web/20180423091842/http://www.equasys.de/colorconversion.html
32pub fn to_srgb(x: Self) color.sRGB {35pub 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,...@@ -67,7 +67,10 @@ pub fn format(x: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions,
67 });67 });
68}68}
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
72// https://www.w3.org/TR/WCAG/#dfn-relative-luminance75// https://www.w3.org/TR/WCAG/#dfn-relative-luminance
73// https://webstore.iec.ch/publication/616976// https://webstore.iec.ch/publication/6169