| author | |
| committer | |
| log | 14e9e3945fb550b52f98f7aae667b7609c5c63f5 |
| tree | 938adaae5611f9dd5e6615e334f59e5f42c0b82b |
| parent | 43b07dfd9ec20389b203efaa03ed6419abecb93c |
| signature |
6 files changed, 24 insertions(+), 6 deletions(-)
HSL.zig+4-1| ... | ... | @@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool { |
| 27 | 27 | return x.h == y.h and x.s == y.s and x.l == y.l and x.a == y.a; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | pub usingnamespace _x.mixin(@This(), f32, .h, .s, .l); | |
| 30 | const M = _x.mixin(@This(), f32, .h, .s, .l); | |
| 31 | pub const to_vec = M.to_vec; | |
| 32 | pub const from_vec = M.from_vec; | |
| 33 | pub const to_array = M.to_array; | |
| 31 | 34 | |
| 32 | 35 | // https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB |
| 33 | 36 | // 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 | 27 | return x.h == y.h and x.s == y.s and x.v == y.v and x.a == y.a; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | pub usingnamespace _x.mixin(@This(), f32, .h, .s, .v); | |
| 30 | const M = _x.mixin(@This(), f32, .h, .s, .v); | |
| 31 | pub const to_vec = M.to_vec; | |
| 32 | pub const from_vec = M.from_vec; | |
| 33 | pub const to_array = M.to_array; | |
| 31 | 34 | |
| 32 | 35 | // https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB |
| 33 | 36 | // 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 | 34 | return (0.2126 * r) + (0.7152 * g) + (0.0722 * b); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | pub usingnamespace _x.mixin(@This(), f32, .r, .g, .b); | |
| 37 | const M = _x.mixin(@This(), f32, .r, .g, .b); | |
| 38 | pub const to_vec = M.to_vec; | |
| 39 | pub const from_vec = M.from_vec; | |
| 40 | pub const to_array = M.to_array; | |
| 38 | 41 | |
| 39 | 42 | // https://gamedev.stackexchange.com/a/194038 |
| 40 | 43 | pub fn to_srgb(x: Self) color.sRGB { |
YCbCr.zig+4-1| ... | ... | @@ -27,7 +27,10 @@ pub fn eql(x: Self, y: Self) bool { |
| 27 | 27 | return x.y == y.y and x.cb == y.cb and x.cr == y.cr and x.a == y.a; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | pub usingnamespace _x.mixin(@This(), u8, .y, .cb, .cr); | |
| 30 | const M = _x.mixin(@This(), u8, .y, .cb, .cr); | |
| 31 | pub const to_vec = M.to_vec; | |
| 32 | pub const from_vec = M.from_vec; | |
| 33 | pub const to_array = M.to_array; | |
| 31 | 34 | |
| 32 | 35 | pub fn to_srgb(x: Self) color.sRGB { |
| 33 | 36 | // zig fmt: off |
YUV.zig+4-1| ... | ... | @@ -26,7 +26,10 @@ pub fn eql(x: Self, y: Self) bool { |
| 26 | 26 | return x.y == y.y and x.u == y.u and x.v == y.v and x.a == y.a; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | pub usingnamespace _x.mixin(@This(), f32, .y, .u, .v); | |
| 29 | pub const M = _x.mixin(@This(), f32, .y, .u, .v); | |
| 30 | pub const to_vec = M.to_vec; | |
| 31 | pub const from_vec = M.from_vec; | |
| 32 | pub const to_array = M.to_array; | |
| 30 | 33 | |
| 31 | 34 | // https://web.archive.org/web/20180423091842/http://www.equasys.de/colorconversion.html |
| 32 | 35 | pub 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 | 67 | }); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | pub usingnamespace _x.mixin(@This(), u8, .r, .g, .b); | |
| 70 | const M = _x.mixin(@This(), u8, .r, .g, .b); | |
| 71 | pub const to_vec = M.to_vec; | |
| 72 | pub const from_vec = M.from_vec; | |
| 73 | pub const to_array = M.to_array; | |
| 71 | 74 | |
| 72 | 75 | // https://www.w3.org/TR/WCAG/#dfn-relative-luminance |
| 73 | 76 | // https://webstore.iec.ch/publication/6169 |