ezgl  1.0.1
An Easy Graphics & GUI Library
color.hpp
1 /*
2  * Copyright 2019-2022 University of Toronto
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Authors: Mario Badr, Sameh Attia, Tanner Young-Schultz and Vaughn Betz
17  */
18 
19 #ifndef EZGL_COLOR_HPP
20 #define EZGL_COLOR_HPP
21 
22 #include <cstdint>
23 
24 namespace ezgl {
25 
31 struct color {
35  constexpr color() noexcept
36  : red(0), green(0), blue(0), alpha(255)
37  {
38  }
39 
48  constexpr color(std::uint_fast8_t r,
49  std::uint_fast8_t g,
50  std::uint_fast8_t b,
51  std::uint_fast8_t a = 255) noexcept
52  : red(r), green(g), blue(b), alpha(a)
53  {
54  }
55 
59  std::uint_fast8_t red;
60 
64  std::uint_fast8_t green;
65 
69  std::uint_fast8_t blue;
70 
74  std::uint_fast8_t alpha;
75 
79  bool operator==(const color &rhs) const
80  {
81  return red == rhs.red && green == rhs.green && blue == rhs.blue && alpha == rhs.alpha;
82  }
83 
87  bool operator!=(const color &rhs) const
88  {
89  return !(rhs == *this);
90  }
91 };
92 
93 static constexpr color WHITE(0xFF, 0xFF, 0xFF);
94 static constexpr color BLACK(0x00, 0x00, 0x00);
95 static constexpr color GREY_55(0x8C, 0x8C, 0x8C);
96 static constexpr color GREY_75(0xBF, 0xBF, 0xBF);
97 static constexpr color RED(0xFF, 0x00, 0x00);
98 static constexpr color ORANGE(0xFF, 0xA5, 0x00);
99 static constexpr color YELLOW(0xFF, 0xFF, 0x00);
100 static constexpr color GREEN(0x00, 0xFF, 0x00);
101 static constexpr color CYAN(0x00, 0xFF, 0xFF);
102 static constexpr color BLUE(0x00, 0x00, 0xFF);
103 static constexpr color PURPLE(0xA0, 0x20, 0xF0);
104 static constexpr color PINK(0xFF, 0xC0, 0xCB);
105 static constexpr color LIGHT_PINK(0xFF, 0xB6, 0xC1);
106 static constexpr color DARK_GREEN(0x00, 0x64, 0x00);
107 static constexpr color MAGENTA(0xFF, 0x00, 0xFF);
108 static constexpr color BISQUE(0xFF, 0xE4, 0xC4);
109 static constexpr color LIGHT_SKY_BLUE(0x87, 0xCE, 0xFA);
110 static constexpr color THISTLE(0xD8, 0xBF, 0xD8);
111 static constexpr color PLUM(0xDD, 0xA0, 0xDD);
112 static constexpr color KHAKI(0xF0, 0xE6, 0x8C);
113 static constexpr color CORAL(0xFF, 0x7F, 0x50);
114 static constexpr color TURQUOISE(0x40, 0xE0, 0xD0);
115 static constexpr color MEDIUM_PURPLE(0x93, 0x70, 0xDB);
116 static constexpr color DARK_SLATE_BLUE(0x48, 0x3D, 0x8B);
117 static constexpr color DARK_KHAKI(0xBD, 0xB7, 0x6B);
118 static constexpr color LIGHT_MEDIUM_BLUE(0x44, 0x44, 0xFF);
119 static constexpr color SADDLE_BROWN(0x8B, 0x45, 0x13);
120 static constexpr color FIRE_BRICK(0xB2, 0x22, 0x22);
121 static constexpr color LIME_GREEN(0x32, 0xCD, 0x32);
122 }
123 
124 #endif //EZGL_COLOR_HPP
A library for creating a graphical user interface.
Definition: application.hpp:40
Represents a color as a mixture or red, green, and blue as well as the transparency level.
Definition: color.hpp:31
bool operator==(const color &rhs) const
Test for equality.
Definition: color.hpp:79
constexpr color(std::uint_fast8_t r, std::uint_fast8_t g, std::uint_fast8_t b, std::uint_fast8_t a=255) noexcept
Create a color.
Definition: color.hpp:48
std::uint_fast8_t green
The green component of the color, between 0 and 255.
Definition: color.hpp:64
std::uint_fast8_t alpha
The amount of transparency, between 0 and 255.
Definition: color.hpp:74
bool operator!=(const color &rhs) const
Test for inequality.
Definition: color.hpp:87
std::uint_fast8_t red
A red component of the color, between 0 and 255.
Definition: color.hpp:59
std::uint_fast8_t blue
The blue component of the color, between 0 and 255.
Definition: color.hpp:69
constexpr color() noexcept
Default constructor: Create a black color.
Definition: color.hpp:35