SDLPainter
0.1.0
QPainter benzeri SDL3 + OpenGL/Vulkan 2D çizim kütüphanesi
Toggle main menu visibility
Yüklüyor...
Arıyor...
Eşleşme Yok
color.h
1
#pragma once
2
3
#include <cstdint>
4
5
namespace
sdl_painter {
6
8
struct
Color
{
9
uint8_t r{0};
10
uint8_t g{0};
11
uint8_t b{0};
12
uint8_t a{255};
13
15
constexpr
Color
() =
default
;
16
18
constexpr
Color
(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ = 255)
19
: r(r_), g(g_), b(b_), a(a_) {}
20
22
[[nodiscard]]
float
RedF
() const noexcept {
23
return
static_cast<
float
>
(r) / 255.0F;
24
}
25
[[nodiscard]]
float
GreenF() const noexcept {
26
return
static_cast<
float
>
(g) / 255.0F;
27
}
28
[[nodiscard]]
float
BlueF() const noexcept {
29
return
static_cast<
float
>
(b) / 255.0F;
30
}
31
[[nodiscard]]
float
AlphaF() const noexcept {
32
return
static_cast<
float
>
(a) / 255.0F;
33
}
34
35
[[nodiscard]]
bool
operator==(
const
Color
& other)
const
noexcept
{
36
return
r == other.r && g == other.g && b == other.b && a == other.a;
37
}
38
[[nodiscard]]
bool
operator!=(
const
Color
& other)
const
noexcept
{
39
return
!(*
this
== other);
40
}
41
42
// Yaygın renkler
43
[[nodiscard]]
static
constexpr
Color
Black() noexcept {
return
{0, 0, 0}; }
44
[[nodiscard]]
static
constexpr
Color
White() noexcept {
45
return
{255, 255, 255};
46
}
47
[[nodiscard]]
static
constexpr
Color
Red() noexcept {
return
{255, 0, 0}; }
48
[[nodiscard]]
static
constexpr
Color
Green() noexcept {
return
{0, 255, 0}; }
49
[[nodiscard]]
static
constexpr
Color
Blue() noexcept {
return
{0, 0, 255}; }
50
[[nodiscard]]
static
constexpr
Color
Transparent() noexcept {
51
return
{0, 0, 0, 0};
52
}
53
};
54
55
}
// namespace sdl_painter
sdl_painter::Color::Color
constexpr Color()=default
Varsayılan siyah, tam opak renk.
sdl_painter::Color::Color
constexpr Color(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_=255)
RGBA değerleriyle renk oluştur.
Definition
color.h:18
sdl_painter::Color::RedF
float RedF() const noexcept
Rengi [0.0, 1.0] aralığında normalize edilmiş float olarak döndür.
Definition
color.h:22
include
sdl_painter
color.h
Oluşturan
1.17.0