aboutsummaryrefslogtreecommitdiff
path: root/color.cc
blob: c1eac72b76a9cb2013153ba291eea967e8e6c4f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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';
}