2020-06-01 02:49:50 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-20 02:19:28 +01:00
|
|
|
#include "error.h"
|
|
|
|
#include "vec3.h"
|
2020-06-01 02:49:50 +02:00
|
|
|
|
2023-02-17 23:55:31 +01:00
|
|
|
// for writing to stdout
|
2020-06-01 02:49:50 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2023-02-17 23:55:31 +01:00
|
|
|
// for writing to socket
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2023-02-20 02:19:28 +01:00
|
|
|
class colour : public vec3
|
2023-02-17 23:55:31 +01:00
|
|
|
{
|
2023-02-20 02:19:28 +01:00
|
|
|
using vec3::vec3;
|
2023-02-17 23:55:31 +01:00
|
|
|
|
2023-02-20 02:19:28 +01:00
|
|
|
public:
|
|
|
|
friend colour operator*(const colour& u, const colour& v);
|
|
|
|
friend colour lerp(const colour& a, const colour& b, double t);
|
2023-02-17 23:55:31 +01:00
|
|
|
|
2023-02-20 02:19:28 +01:00
|
|
|
colour correct_gamma(int samples);
|
2023-02-17 23:55:31 +01:00
|
|
|
|
2023-02-20 02:19:28 +01:00
|
|
|
friend void write_colour_to_socket(int sockfd, colour pixel_colour, int samples_per_pixel);
|
|
|
|
friend void write_colour_to_stream(std::ostream &out, colour pixel_colour, int samples_per_pixel);
|
|
|
|
friend int format_component(double component);
|
|
|
|
};
|
2023-02-17 23:55:31 +01:00
|
|
|
|
2023-02-20 02:19:28 +01:00
|
|
|
const colour pink(254.0/255.0, 226.0/255.0, 170.0/255.0);
|
|
|
|
const colour grey(0.133, 0.133, 0.133);
|
2023-02-17 23:55:31 +01:00
|
|
|
|