MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_color32.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_COLOR32_H_1678469912
12#define INCGUARD_MGL_COLOR32_H_1678469912
13
15
16namespace MGL
17{
19struct Color32
20{
21 uint8_t red;
22 uint8_t green;
23 uint8_t blue;
24 uint8_t alpha;
25
26 /* ------------------------------------------------------------------------- */
30 /* ------------------------------------------------------------------------- */
31 constexpr Color32() noexcept
32 : red(0)
33 , green(0)
34 , blue(0)
35 , alpha(0)
36 {}
37
38 /* ------------------------------------------------------------------------- */
46 /* ------------------------------------------------------------------------- */
47 constexpr Color32(uint8_t inRed, uint8_t inGreen, uint8_t inBlue, uint8_t inAlpha = 255) noexcept
48 : red(inRed)
49 , green(inGreen)
50 , blue(inBlue)
51 , alpha(inAlpha)
52 {}
53
54 /* ------------------------------------------------------------------------- */
59 /* ------------------------------------------------------------------------- */
60 constexpr Color32(uint32_t rgba) noexcept
61 : red(static_cast<uint8_t>(rgba >> 24))
62 , green(static_cast<uint8_t>((rgba >> 16) & 0xFF))
63 , blue((static_cast<uint8_t>(rgba >> 8) & 0xFF))
64 , alpha(static_cast<uint8_t>(rgba & 0xFF))
65 {}
66
67 /* ------------------------------------------------------------------------- */
72 /* ------------------------------------------------------------------------- */
73 constexpr Color32(XColor xcolor) noexcept
74 : Color32(GetXColorCode(xcolor))
75 {}
76
77 /* ------------------------------------------------------------------------- */
81 /* ------------------------------------------------------------------------- */
82 constexpr operator Color() const noexcept
83 {
84 Color color;
85 color.red = static_cast<float>(red) / 255.0f;
86 color.green = static_cast<float>(green) / 255.0f;
87 color.blue = static_cast<float>(blue) / 255.0f;
88 color.alpha = static_cast<float>(alpha) / 255.0f;
89 return color;
90 }
91};
92
93} // namespace MGL
94#endif // INCGUARD_MGL_COLOR32_H_1678469912
95
96// vim: et ts=4 sw=4 sts=4
MGL 色情報
XColor
xterm 256カラー
Definition mgl_color_xterm.h:21
constexpr uint32_t GetXColorCode(XColor xcolor) noexcept
XColorのカラーコードを取得
Definition mgl_color_xterm.h:97
各8bit RGBAの色情報
Definition mgl_color32.h:20
uint8_t blue
青成分
Definition mgl_color32.h:23
uint8_t green
緑成分
Definition mgl_color32.h:22
constexpr Color32(uint8_t inRed, uint8_t inGreen, uint8_t inBlue, uint8_t inAlpha=255) noexcept
色を指定して初期化
Definition mgl_color32.h:47
uint8_t red
赤成分
Definition mgl_color32.h:21
constexpr Color32(XColor xcolor) noexcept
xtermカラーで色を指定して初期化
Definition mgl_color32.h:73
uint8_t alpha
アルファ値
Definition mgl_color32.h:24
constexpr Color32(uint32_t rgba) noexcept
32-bit RGBA値で初期化
Definition mgl_color32.h:60
constexpr Color32() noexcept
ゼロ初期化
Definition mgl_color32.h:31
色情報
Definition mgl_color.h:22
float red
赤成分
Definition mgl_color.h:23
float green
緑成分
Definition mgl_color.h:24
float blue
青成分
Definition mgl_color.h:25
float alpha
アルファ値
Definition mgl_color.h:26