MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_color.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_COLOR_H_1606630679
12#define INCGUARD_MGL_COLOR_H_1606630679
13
14#include <cstdint>
15
16#include "mgl_color_xterm.h"
17
18namespace MGL
19{
21struct Color
22{
23 float red;
24 float green;
25 float blue;
26 float alpha;
27
28 /* ------------------------------------------------------------------------- */
32 /* ------------------------------------------------------------------------- */
33 constexpr Color() noexcept
34 : red(0.0f)
35 , green(0.0f)
36 , blue(0.0f)
37 , alpha(0.0f)
38 {}
39
40 /* ------------------------------------------------------------------------- */
48 /* ------------------------------------------------------------------------- */
49 constexpr Color(float inRed, float inGreen, float inBlue, float inAlpha = 1.0f) noexcept
50 : red(inRed)
51 , green(inGreen)
52 , blue(inBlue)
53 , alpha(inAlpha)
54 {}
55
56 /* ------------------------------------------------------------------------- */
61 /* ------------------------------------------------------------------------- */
62 constexpr Color(uint32_t rgba) noexcept
63 : red(static_cast<float>(rgba >> 24u) / 255.0f)
64 , green(static_cast<float>((rgba >> 16u) & 0xFFu) / 255.0f)
65 , blue(static_cast<float>((rgba >> 8u) & 0xFFu) / 255.0f)
66 , alpha(static_cast<float>(rgba & 0xFFu) / 255.0f)
67 {}
68
69 /* ------------------------------------------------------------------------- */
74 /* ------------------------------------------------------------------------- */
75 constexpr Color(XColor xcolor) noexcept
76 : Color(GetXColorCode(xcolor))
77 {}
78};
79
80constexpr Color kColorRed = Color(1.0f, 0.0f, 0.0f, 1.0f);
81constexpr Color kColorGreen = Color(0.0f, 1.0f, 0.0f, 1.0f);
82constexpr Color kColorBlue = Color(0.0f, 0.0f, 1.0f, 1.0f);
83constexpr Color kColorBlack = Color(0.0f, 0.0f, 0.0f, 1.0f);
84constexpr Color kColorWhite = Color(1.0f, 1.0f, 1.0f, 1.0f);
85
86} // namespace MGL
87
88#endif // INCGUARD_MGL_COLOR_H_1606630679
89
90// vim: et ts=4 sw=4 sts=4
constexpr Color kColorBlue
Definition mgl_color.h:82
constexpr Color kColorGreen
Definition mgl_color.h:81
constexpr Color kColorWhite
Definition mgl_color.h:84
constexpr Color kColorBlack
Definition mgl_color.h:83
constexpr Color kColorRed
Definition mgl_color.h:80
MGL xterm-256カラー定義
XColor
xterm 256カラー
Definition mgl_color_xterm.h:21
constexpr uint32_t GetXColorCode(XColor xcolor) noexcept
XColorのカラーコードを取得
Definition mgl_color_xterm.h:97
色情報
Definition mgl_color.h:22
constexpr Color() noexcept
ゼロ初期化
Definition mgl_color.h:33
float red
赤成分
Definition mgl_color.h:23
float green
緑成分
Definition mgl_color.h:24
constexpr Color(uint32_t rgba) noexcept
32-bit RGBA値で初期化
Definition mgl_color.h:62
float blue
青成分
Definition mgl_color.h:25
float alpha
アルファ値
Definition mgl_color.h:26
constexpr Color(XColor xcolor) noexcept
xtermカラーで色を指定して初期化
Definition mgl_color.h:75
constexpr Color(float inRed, float inGreen, float inBlue, float inAlpha=1.0f) noexcept
色を指定して初期化
Definition mgl_color.h:49