SDLPainter 0.1.0
QPainter benzeri SDL3 + OpenGL/Vulkan 2D çizim kütüphanesi
Yüklüyor...
Arıyor...
Eşleşme Yok
pen.h
1#pragma once
2
3#include "sdl_painter/color.h"
4
5namespace sdl_painter {
6
8class Pen {
9 public:
11 Pen() = default;
12
16 explicit Pen(const Color& color, float width = 1.0F)
17 : mColor(color), mWidth(width) {}
18
29 Pen(const Color& color, float width, const Color& outline_color,
30 float outline_width)
31 : mColor(color),
32 mWidth(width),
33 mOutlineColor(outline_color),
34 mOutlineWidth(outline_width) {}
35
37 [[nodiscard]] const Color& GetColor() const noexcept { return mColor; }
38
40 [[nodiscard]] float GetWidth() const noexcept { return mWidth; }
41
43 [[nodiscard]] const Color& GetOutlineColor() const noexcept {
44 return mOutlineColor;
45 }
46
48 [[nodiscard]] float GetOutlineWidth() const noexcept { return mOutlineWidth; }
49
51 void SetColor(const Color& color) noexcept { mColor = color; }
52
54 void SetWidth(float width) noexcept { mWidth = width; }
55
57 void SetOutlineColor(const Color& color) noexcept { mOutlineColor = color; }
58
60 void SetOutlineWidth(float width) noexcept { mOutlineWidth = width; }
61
63 [[nodiscard]] bool IsVisible() const noexcept {
64 return mColor.a > 0 && mWidth > 0.0F;
65 }
66
68 [[nodiscard]] bool HasOutline() const noexcept {
69 return mOutlineColor.a > 0 && mOutlineWidth > 0.0F;
70 }
71
72 [[nodiscard]] bool operator==(const Pen& other) const noexcept {
73 return mColor == other.mColor && mWidth == other.mWidth &&
74 mOutlineColor == other.mOutlineColor &&
75 mOutlineWidth == other.mOutlineWidth;
76 }
77 [[nodiscard]] bool operator!=(const Pen& other) const noexcept {
78 return !(*this == other);
79 }
80
82 [[nodiscard]] static Pen NoPen() noexcept {
83 return Pen(Color::Transparent(), 0.0F);
84 }
85
86 private:
87 Color mColor{Color::Black()};
88 float mWidth{1.0F};
89 Color mOutlineColor{Color::Transparent()};
90 float mOutlineWidth{0.0F};
91};
92
93} // namespace sdl_painter
Çizgi stili — renk, kalınlık ve isteğe bağlı dış kontur.
Definition pen.h:8
const Color & GetOutlineColor() const noexcept
Dış kontur rengini döndür.
Definition pen.h:43
void SetOutlineWidth(float width) noexcept
Dış kontur kalınlığını ayarla.
Definition pen.h:60
bool IsVisible() const noexcept
Kalem görünür mü? (alpha > 0 ve width > 0).
Definition pen.h:63
void SetWidth(float width) noexcept
Çizgi kalınlığını ayarla.
Definition pen.h:54
static Pen NoPen() noexcept
Şeffaf (çizim yapmayan) kalem.
Definition pen.h:82
bool HasOutline() const noexcept
Kalemin görünür bir dış konturu var mı?
Definition pen.h:68
Pen(const Color &color, float width=1.0F)
Renk ve kalınlıkla kalem oluştur.
Definition pen.h:16
float GetWidth() const noexcept
Çizgi kalınlığını döndür.
Definition pen.h:40
void SetOutlineColor(const Color &color) noexcept
Dış kontur rengini ayarla.
Definition pen.h:57
const Color & GetColor() const noexcept
Çizgi rengini döndür.
Definition pen.h:37
float GetOutlineWidth() const noexcept
Dış kontur kalınlığını döndür.
Definition pen.h:48
void SetColor(const Color &color) noexcept
Çizgi rengini ayarla.
Definition pen.h:51
Pen(const Color &color, float width, const Color &outline_color, float outline_width)
Dış konturlu (outline) kalem oluştur.
Definition pen.h:29
Pen()=default
Varsayılan kalem: siyah, 1 piksel kalınlık.
RGBA renk temsili. Her kanal [0, 255] aralığında.
Definition color.h:8