diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-03-09 02:21:09 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-03-09 02:21:09 +0800 |
| commit | 2a65ece16cd237d56c9dac8d9d3d680e9d34b774 (patch) | |
| tree | 897cbb982ba4e44ee6c40d90223fa1732adac036 /color.cc | |
| parent | 0671c86d0f0dccd6e94766834c41807b7d6b5388 (diff) | |
| download | ray-tracing-2a65ece16cd237d56c9dac8d9d3d680e9d34b774.tar.gz ray-tracing-2a65ece16cd237d56c9dac8d9d3d680e9d34b774.tar.xz | |
Create class vec3
Diffstat (limited to 'color.cc')
| -rw-r--r-- | color.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/color.cc b/color.cc new file mode 100644 index 0000000..c1eac72 --- /dev/null +++ b/color.cc @@ -0,0 +1,15 @@ +#include "color.h" + +void write_color(std::ostream &out, const color &pixel_color){ + auto r = pixel_color.x(); + auto g = pixel_color.y(); + auto b = pixel_color.z(); + + // Translate the [0,1] component values to the byte range [0,255]. + int rbyte = int(255.999 * r); + int gbyte = int(255.999 * g); + int bbyte = int(255.999 * b); + + // Write out the pixel color components. + out << rbyte << ' ' << gbyte << ' ' << bbyte << '\n'; +}
\ No newline at end of file |
