aboutsummaryrefslogtreecommitdiff
path: root/src/core/spectrum.hpp
blob: de9355d80a5610cdd231bc36261b17bb9b60b493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef SPECTRUM_H
#define SPECTRUM_H

#include "core/common.hpp"

// Contains a RGB spectrum value
class Spectrum {
public:
    Spectrum(double v = 0);
    static Spectrum FromRGB(double r, double g, double b);

    Spectrum &operator+=(const Spectrum &o);
    Spectrum &operator*=(double o);
    Spectrum operator+(const Spectrum &o) const;
    Spectrum operator-(const Spectrum &o) const;
    Spectrum operator*(const Spectrum &o) const;
    Spectrum operator/(const Spectrum &o) const;

    Spectrum clamp(double low = 0, double high = INFINITY) const;

    double R() const { return c[0]; }
    double G() const { return c[1]; }
    double B() const { return c[2]; }

private:
    double c[3];
};

#endif