From 002bc486968684b4dba41ccc14a1833cb53922f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Thu, 10 Oct 2024 20:06:11 +0900 Subject: [PATCH] colorspace: replace if statements with if expressions --- src/colorspace.zig | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/colorspace.zig b/src/colorspace.zig index b9329ff..839fc75 100644 --- a/src/colorspace.zig +++ b/src/colorspace.zig @@ -298,23 +298,9 @@ pub const Rgb = struct { var g: f64 = @as(f64, @floatFromInt(self.g)) / 255; var b: f64 = @as(f64, @floatFromInt(self.b)) / 255; - if (r > 0.04045) { - r = pow(f64, (r + 0.055) / 1.055, 2.4); - } else { - r /= 12.92; - } - - if (g > 0.04045) { - g = pow(f64, (g + 0.055) / 1.055, 2.4); - } else { - g /= 12.92; - } - - if (b > 0.04045) { - b = pow(f64, (b + 0.055) / 1.055, 2.4); - } else { - b /= 12.92; - } + r = if (r > 0.04045) pow(f64, (r + 0.055) / 1.055, 2.4) else r / 12.92; + g = if (g > 0.04045) pow(f64, (g + 0.055) / 1.055, 2.4) else g / 12.92; + b = if (b > 0.04045) pow(f64, (b + 0.055) / 1.055, 2.4) else b / 12.92; return .{ .x = (r * 0.4124 + g * 0.3576 + b * 0.1805) * 100,