Add Colour implementation

This commit is contained in:
Godzil
2020-02-14 15:08:40 +00:00
parent 332e73a3d9
commit f3678992c5
5 changed files with 97 additions and 4 deletions

View File

@@ -1,10 +1,10 @@
# To simplify testing, the app is build in two passes,
# First most is build as a library
add_library(rayonnement STATIC math_helper.cpp)
add_library(rayonnement STATIC)
set(RAY_HEADERS include/tuples.h include/math_helper.h)
set(RAY_SOURCES tuples.cpp)
set(RAY_HEADERS include/tuples.h include/math_helper.h include/colour.h)
set(RAY_SOURCES tuples.cpp math_helper.cpp colour.cpp)
target_include_directories(rayonnement PUBLIC include)
target_sources(rayonnement PRIVATE ${RAY_HEADERS} ${RAY_SOURCES})

10
source/colour.cpp Normal file
View File

@@ -0,0 +1,10 @@
/*
* DoRayMe - a quick and dirty Raytracer
* Colour implementation
*
* Created by Manoël Trapier
* Copyright (c) 2020 986-Studio.
*
*/
#include "colour.h"

32
source/include/colour.h Normal file
View File

@@ -0,0 +1,32 @@
/*
* DoRayMe - a quick and dirty Raytracer
* Colour header
*
* Created by Manoël Trapier
* Copyright (c) 2020 986-Studio.
*
*/
#ifndef DORAYME_COLOUR_H
#define DORAYME_COLOUR_H
#include <tuples.h>
class Colour : public Tuple
{
public:
Colour(double red, double green, double blue) : Tuple(red, green, blue, 0) {};
double red() { return this->x; };
double green() { return this->y; };
double blue() { return this->z; };
double red(double v) { this->x = v; return v; };
double green(double v) { this->y = v; return v; };
double blue(double v) { this->z = v; return v; };
using Tuple::operator*;
Colour operator*(const Colour &b) const { return Colour(this->x * b.x,
this->y * b.y,
this->z * b.z); };
};
#endif /* DORAYME_COLOUR_H */