scatter 0.1.0
Colour.hpp
1/*
2 * Copyright (C) Tobias Löw (tobi.loew@protonmail.ch)
3 *
4 * This file is part of Scatter
5 *
6 * Scatter is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Scatter is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Scatter. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <array>
23#include <string>
24#include <vector>
25
26namespace scatter
27{
33 class Colour
34 {
35 public:
41
51 Colour(const double &r, const double &g, const double &b, const double &a);
52
62 Colour(const int &r, const int &g, const int &b, const int &a);
63
70 Colour(const int &hex);
71
76 virtual ~Colour();
77
82 const double &r() const;
83
88 const double &g() const;
89
94 const double &b() const;
95
100 const double &a() const;
101
102 public:
103 bool operator==(const Colour &other) const;
104
105 protected:
112 Colour(const std::array<double, 4> &c);
113
114 private:
116 std::array<double, 4> data_;
117
118 public:
120 static Colour red;
122 static Colour blue;
124 static Colour green;
128 static Colour black;
130 static Colour white;
132 static Colour cyan;
134 static Colour pink;
135
136 public:
146 static Colour mix(const double &weight, const Colour &colour1, const Colour &colour2);
147
155 static Colour createFromHex(const int &hex);
156 };
157
158} // namespace scatter
define a RGBA colour
Definition Colour.hpp:34
Colour()
construct a black Colour
static Colour black
define black colour
Definition Colour.hpp:128
Colour(const double &r, const double &g, const double &b, const double &a)
constructor
Colour(const int &hex)
constructor
const double & b() const
return the blue part
static Colour createFromHex(const int &hex)
[brief description]
static Colour cyan
define cyan colour
Definition Colour.hpp:132
static Colour blue
define blue colour
Definition Colour.hpp:122
static Colour yellow
define yellow colour
Definition Colour.hpp:126
static Colour mix(const double &weight, const Colour &colour1, const Colour &colour2)
[brief description]
static Colour red
define red colour
Definition Colour.hpp:120
const double & r() const
return the red part
const double & a() const
return the alpha part
Colour(const std::array< double, 4 > &c)
internal constructor
static Colour white
define white colour
Definition Colour.hpp:130
const double & g() const
return the green part
static Colour green
define green colour
Definition Colour.hpp:124
Colour(const int &r, const int &g, const int &b, const int &a)
constructor
virtual ~Colour()
destructor
static Colour pink
define pink colour
Definition Colour.hpp:134