Ray Tracer  2020
Colour.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef COLOUR_H_INCLUDED
4 #define COLOUR_H_INCLUDED
25 class Colour {
26 
27 public:
28 
33  Colour();
34 
35 
44  Colour(double r, double g, double b);
45 
46 
51  Colour(const Colour& colour);
52 
54  ~Colour();
55 
61  Colour& operator=(const Colour& colour);
62 
69  Colour operator-() const;
70 
71 
79  Colour& operator+=(const Colour& colour);
80 
88  Colour& operator-=(const Colour& colour);
89 
97  Colour& operator*=(const Colour& colour);
98 
106  Colour& operator*=(double s);
107 
115  Colour& operator/=(double s);
116 
123  void clip();
124 
125  double red;
126  double green;
127  double blue;
128 
129 };
130 
140 Colour operator+(const Colour& lhs, const Colour& rhs);
141 
151 Colour operator-(const Colour& lhs, const Colour& rhs);
152 
163 Colour operator*(const Colour& lhs, const Colour& rhs);
164 
174 Colour operator*(double s, const Colour& colour);
175 
185 Colour operator*(const Colour& colour, double s);
186 
196 Colour operator/(const Colour& colour, double s);
197 
198 
199 #endif
Class to store colour information.
Definition: Colour.h:25
double blue
The blue component of the Colour.
Definition: Colour.h:127
double red
The red component of the Colour.
Definition: Colour.h:125
double green
The green component of the Colour.
Definition: Colour.h:126
Colour & operator*=(const Colour &colour)
Colour multiplication-assignment operator.
Definition: Colour.cpp:63
Colour & operator-=(const Colour &colour)
Colour subtraction-assignment operator.
Definition: Colour.cpp:51
Colour()
Colour default constructor.
Definition: Colour.cpp:3
Colour & operator=(const Colour &colour)
Colour assignment operator.
Definition: Colour.cpp:22
Colour operator-() const
Colour unary negation.
Definition: Colour.cpp:31
Colour operator/(const Colour &colour, double s)
Colour-scalar division.
Definition: Colour.cpp:85
~Colour()
Colour destructor.
Definition: Colour.cpp:18
Colour & operator/=(double s)
Colour-scalar division-assignment operator.
Definition: Colour.cpp:89
void clip()
Enforce bounds on Colour components.
Definition: Colour.cpp:96
Colour operator+(const Colour &lhs, const Colour &rhs)
Colour addition.
Definition: Colour.cpp:35
Colour & operator+=(const Colour &colour)
Colour addition-assignment operator.
Definition: Colour.cpp:39
Colour operator-(const Colour &lhs, const Colour &rhs)
Colour subtraction.
Definition: Colour.cpp:47
friend Matrix operator*(const Matrix &lhs, const Matrix &rhs)
Matrix-Matrix multiplication operator.
Definition: Matrix.cpp:151