From 31aebe5ade13f95594d190bbed095b82cd17d171 Mon Sep 17 00:00:00 2001 From: Wander_lust Date: Tue, 17 Feb 2026 02:11:41 +0530 Subject: [PATCH] refactor color.h --- include/color.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/color.h b/include/color.h index a3d9ab5..9bfa7c7 100644 --- a/include/color.h +++ b/include/color.h @@ -19,18 +19,18 @@ inline void write_color(std::ostream& out, const color& pixel_color) { auto g = pixel_color.y(); auto b = pixel_color.z(); - // Apply a linear to gamma transform for gamma 2 + r = linear_to_gamma(r); g = linear_to_gamma(g); b = linear_to_gamma(b); - // Translate the [0,1] component values to the byte range [0,255]. + static const interval intensity(0.000, 0.999); int rbyte = int(256 * intensity.clamp(r)); int gbyte = int(256 * intensity.clamp(g)); int bbyte = int(256 * intensity.clamp(b)); - // Write out the pixel color components. + out << rbyte << ' ' << gbyte << ' ' << bbyte << '\n'; }