authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-09-18 10:16:57 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-09-18 10:16:57 -07:00
logc586d8ba0ca57a50ef2ed5f951b2b4ee9c5361c5
tree499a5cac2cb4ff624b24491312c7b41310b717af
parent68eede0ded013ac7d03dcba3554f30526aba86c9

floating point absolute value is available in @fabs


2 files changed, 1 insertions(+), 5 deletions(-)

sRGB.zig+1-2
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3const std = @import("std");3const std = @import("std");
4const Self = @This();4const Self = @This();
5const color = @import("./mod.zig");5const color = @import("./mod.zig");
6const _x = @import("./x.zig");
76
8r: u8, // red value7r: u8, // red value
9g: u8, // green value8g: u8, // green value
...@@ -123,7 +122,7 @@ pub fn to_hsl(x: Self) color.HSL {...@@ -123,7 +122,7 @@ pub fn to_hsl(x: Self) color.HSL {
123 unreachable;122 unreachable;
124 };123 };
125 const l = (cmax + cmin) / 2;124 const l = (cmax + cmin) / 2;
126 const s = if (delta == 0) 0 else delta / (1 - _x.abs(2 * l - 1));125 const s = if (delta == 0) 0 else delta / (1 - @fabs(2 * l - 1));
127 const a = f.a;126 const a = f.a;
128 return color.HSL.initHSLA(h, s, l, a);127 return color.HSL.initHSLA(h, s, l, a);
129}128}
x.zig deleted-3
...@@ -1,3 +0,0 @@
1pub fn abs(x: f32) f32 {
2 return if (x < 0.0) -x else x;
3}