SDLPainter
1.2.0
SDL3 + OpenGL/Vulkan 2D çizim kütüphanesi
Toggle main menu visibility
Yüklüyor...
Arıyor...
Eşleşme Yok
brush.h
1
#pragma once
2
3
#include "sdl_painter/color.h"
4
#include "sdl_painter/geometry.h"
5
6
#include <cstdint>
7
8
namespace
sdl_painter {
9
11
enum class
BrushType : uint8_t {
12
kSolid,
13
kLinear,
14
kRadial,
15
};
16
34
class
Brush
{
35
public
:
37
Brush
() =
default
;
38
40
explicit
Brush
(
const
Color
& color) : mColor(color) {}
41
51
[[nodiscard]]
static
Brush
LinearGradient
(
const
Point
& start,
52
const
Point
& end,
const
Color
& from,
53
const
Color
& to)
noexcept
{
54
Brush
b;
55
b.mType = BrushType::kLinear;
56
b.mColor = from;
57
b.mColor2 = to;
58
b.mStart = start;
59
b.mEnd = end;
60
return
b;
61
}
62
69
[[nodiscard]]
static
Brush
RadialGradient
(
const
Point
& center,
float
radius,
70
const
Color
& from,
71
const
Color
& to)
noexcept
{
72
Brush
b;
73
b.mType = BrushType::kRadial;
74
b.mColor = from;
75
b.mColor2 = to;
76
b.mStart = center;
77
b.mRadius = radius;
78
return
b;
79
}
80
82
[[nodiscard]] BrushType
GetType
() const noexcept {
return
mType; }
83
85
[[nodiscard]]
bool
IsGradient
() const noexcept {
86
return
mType != BrushType::kSolid;
87
}
88
90
[[nodiscard]]
const
Color
&
GetColor2
() const noexcept {
return
mColor2; }
91
93
[[nodiscard]]
const
Point
&
GetStart
() const noexcept {
return
mStart; }
94
96
[[nodiscard]]
const
Point
&
GetEnd
() const noexcept {
return
mEnd; }
97
99
[[nodiscard]]
float
GetRadius
() const noexcept {
return
mRadius; }
100
102
[[nodiscard]]
const
Color
&
GetColor
() const noexcept {
return
mColor; }
103
105
void
SetColor
(
const
Color
& color)
noexcept
{ mColor = color; }
106
113
[[nodiscard]]
bool
IsVisible
() const noexcept {
114
return
mColor.a > 0 || (
IsGradient
() && mColor2.a > 0);
115
}
116
117
[[nodiscard]]
bool
operator==(
const
Brush
& other)
const
noexcept
{
118
if
(mColor != other.mColor || mType != other.mType) {
119
return
false
;
120
}
121
if
(mType == BrushType::kSolid) {
122
return
true
;
123
}
124
return
mColor2 == other.mColor2 && mStart.x == other.mStart.x &&
125
mStart.y == other.mStart.y && mEnd.x == other.mEnd.x &&
126
mEnd.y == other.mEnd.y && mRadius == other.mRadius;
127
}
128
[[nodiscard]]
bool
operator!=(
const
Brush
& other)
const
noexcept
{
129
return
!(*
this
== other);
130
}
131
133
[[nodiscard]]
static
Brush
NoBrush
() noexcept {
134
return
Brush
(Color::Transparent());
135
}
136
137
private
:
138
Color
mColor{Color::Black()};
139
Color mColor2{Color::White()};
140
Point mStart;
141
Point mEnd;
142
float
mRadius{0.0F};
143
BrushType mType{BrushType::kSolid};
144
};
145
146
}
// namespace sdl_painter
sdl_painter::Brush
Dolgu stili — düz renk veya gradient.
Definition
brush.h:34
sdl_painter::Brush::LinearGradient
static Brush LinearGradient(const Point &start, const Point &end, const Color &from, const Color &to) noexcept
Doğrusal gradient fırça.
Definition
brush.h:51
sdl_painter::Brush::IsVisible
bool IsVisible() const noexcept
Fırça görünür mü? (alpha > 0).
Definition
brush.h:113
sdl_painter::Brush::GetEnd
const Point & GetEnd() const noexcept
Doğrusal gradientte bitiş noktası.
Definition
brush.h:96
sdl_painter::Brush::GetType
BrushType GetType() const noexcept
Fırçanın dolgu türü.
Definition
brush.h:82
sdl_painter::Brush::GetRadius
float GetRadius() const noexcept
Işınsal gradientte yarıçap.
Definition
brush.h:99
sdl_painter::Brush::RadialGradient
static Brush RadialGradient(const Point ¢er, float radius, const Color &from, const Color &to) noexcept
Işınsal gradient fırça.
Definition
brush.h:69
sdl_painter::Brush::GetColor
const Color & GetColor() const noexcept
Dolgu rengini döndür.
Definition
brush.h:102
sdl_painter::Brush::GetStart
const Point & GetStart() const noexcept
Doğrusal gradientte başlangıç, ışınsalda merkez.
Definition
brush.h:93
sdl_painter::Brush::Brush
Brush()=default
Varsayılan fırça: siyah, tam opak.
sdl_painter::Brush::IsGradient
bool IsGradient() const noexcept
Gradient mi? (düz renk değil).
Definition
brush.h:85
sdl_painter::Brush::SetColor
void SetColor(const Color &color) noexcept
Dolgu rengini ayarla.
Definition
brush.h:105
sdl_painter::Brush::Brush
Brush(const Color &color)
Renk ile fırça oluştur.
Definition
brush.h:40
sdl_painter::Brush::GetColor2
const Color & GetColor2() const noexcept
Gradient bitiş rengi (düz fırçada anlamsız).
Definition
brush.h:90
sdl_painter::Brush::NoBrush
static Brush NoBrush() noexcept
Şeffaf (dolgu yapmayan) fırça.
Definition
brush.h:133
sdl_painter::Color
RGBA renk temsili. Her kanal [0, 255] aralığında.
Definition
color.h:8
sdl_painter::Point
2B nokta — float koordinatlar.
Definition
geometry.h:8
include
sdl_painter
brush.h
Oluşturan
1.18.0