gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
color.h
1// © Joseph Cameron - All Rights Reserved
2
3#ifndef GDK_GFX_COLOR_H
4#define GDK_GFX_COLOR_H
5
6#include <iosfwd>
7
8namespace gdk {
11 struct color final {
12 using channel_type = float;
13
14 channel_type r = 0, g = 0, b = 0, a = 1;
15
17 void clamp();
18
21 void operator+=(const color &aOther);
22
24 bool operator==(const color &aOther) const;
26 bool operator!=(const color &aOther) const;
27
29 color(const color &) = default;
31 color& operator=(const color &acolor) = default;
32
34 color(color &&) = default;
36 color& operator=(color &&acolor) = default;
37
39 color() = default;
40
43 color(const channel_type aR,
44 const channel_type aG,
45 const channel_type aB,
46 const channel_type aA = 1);
47
50 //
52 static const color black;
54 static const color white;
56 static const color red;
58 static const color green;
60 static const color dark_green;
62 static const color blue;
65 static const color deathly_pink;
67 static const color cornflower_blue;
69 };
70
71 std::ostream &operator<<(std::ostream &stream, const color &acolor);
72}
73
74#endif
75
Represents a 4 channel color: {Red, Green, Blue, Alpha}. TODO: channel values should be limited to th...
Definition color.h:11
static const color black
opaque black color
Definition color.h:52
static const color green
opaque green color
Definition color.h:58
void operator+=(const color &aOther)
add two colors together. \warn does not clamp values within the normalized range
static const color white
opaque white color
Definition color.h:54
static const color dark_green
opaque dark green color
Definition color.h:60
static const color deathly_pink
Definition color.h:65
color()=default
constructs a color as opaque black
static const color cornflower_blue
an opaque pastel blue color
Definition color.h:67
color(const channel_type aR, const channel_type aG, const channel_type aB, const channel_type aA=1)
constructs a color with provided channel values. Alpha has a default opaque value
color & operator=(const color &acolor)=default
copy semantics
color(color &&)=default
move semantics
color & operator=(color &&acolor)=default
move semantics
static const color red
opaque red color
Definition color.h:56
bool operator==(const color &aOther) const
equality semantics
color(const color &)=default
copy semantics
static const color blue
opaque blue color
Definition color.h:62
bool operator!=(const color &aOther) const
equality semantics
void clamp()
clamp each channel to the [0 - 1] range