Color.cpp
1// Copyright 2019 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4
5#include "smk/Color.hpp"
6
7/// Color namespace
8namespace smk::Color {
9
10/// @brief Build a color from its RGBA components components.
11/// This is equivalent to calling the glm::vec4 constructor.
12/// @param red: The red component in [0,1]
13/// @param blue: The blue component in [0,1]
14/// @param green: The green component in [0,1]
15/// @param alpha: The alpha component in [0,1]
16glm::vec4 RGBA(float red, float green, float blue, float alpha) {
17 return {red, green, blue, alpha};
18}
19
20/// @brief Build an opaque color from its RGB components components.
21/// @param red: The red component in [0,1]
22/// @param blue: The blue component in [0,1]
23/// @param green: The green component in [0,1]
24glm::vec4 RGB(float red, float green, float blue) {
25 return {red, green, blue, 1.F};
26}
27
28// clang-format off
29const glm::vec4 White = {1.F, 1.F, 1.F, 1.F}; ///< White
30const glm::vec4 Black = {0.F, 0.F, 0.F, 1.F}; ///< Black
31const glm::vec4 Grey = {.5f, .5f, .5f, 1.F}; ///< Grey
32const glm::vec4 Red = {1.F, 0.F, 0.F, 1.F}; ///< Red
33const glm::vec4 Green = {0.F, 1.F, 0.F, 1.F}; ///< Green
34const glm::vec4 Blue = {0.F, 0.F, 1.F, 1.F}; ///< Blue
35const glm::vec4 Yellow = {1.F, 1.F, 0.F, 1.F}; ///< Yellow
36const glm::vec4 Magenta = {1.F, 0.F, 1.F, 1.F}; ///< Magenta
37const glm::vec4 Cyan = {0.F, 1.F, 1.F, 1.F}; ///< Cyan
38const glm::vec4 Transparent = {0.F, 0.F, 0.F, 0.F}; ///< Transparent
39// clang-format on
40
41} // namespace smk::Color
Color namespace.
Definition: Color.hpp:11
const glm::vec4 Green
Green.
Definition: Color.cpp:33
const glm::vec4 Black
Black.
Definition: Color.cpp:30
const glm::vec4 Cyan
Cyan.
Definition: Color.cpp:37
const glm::vec4 Transparent
Transparent.
Definition: Color.cpp:38
const glm::vec4 Red
Red.
Definition: Color.cpp:32
const glm::vec4 White
White.
Definition: Color.cpp:29
const glm::vec4 Yellow
Yellow.
Definition: Color.cpp:35
const glm::vec4 Grey
Grey.
Definition: Color.cpp:31
const glm::vec4 Magenta
Magenta.
Definition: Color.cpp:36
const glm::vec4 Blue
Blue.
Definition: Color.cpp:34
glm::vec4 RGB(float red, float green, float blue)
Build an opaque color from its RGB components components.
Definition: Color.cpp:24
glm::vec4 RGBA(float red, float green, float blue, float alpha)
Build a color from its RGBA components components. This is equivalent to calling the glm::vec4 constr...
Definition: Color.cpp:16