3#include "sdl_painter/brush.h"
4#include "sdl_painter/color.h"
5#include "sdl_painter/export.h"
6#include "sdl_painter/font.h"
7#include "sdl_painter/frame_stats.h"
8#include "sdl_painter/geometry.h"
11#include "sdl_painter/image.h"
12#include "sdl_painter/pen.h"
13#include "sdl_painter/renderer.h"
14#include "sdl_painter/vertex.h"
31namespace sdl_painter {
42 BlendMode blend_mode{BlendMode::kAlpha};
61 Painter(SDL_Window* window, RendererBackend backend);
76 Painter(std::unique_ptr<IRenderer> renderer, int32_t viewport_width,
77 int32_t viewport_height);
88 [[nodiscard]]
bool IsValid() const noexcept {
return mRenderer !=
nullptr; }
131 void SetViewport(int32_t x, int32_t y, int32_t width, int32_t height);
170 [[nodiscard]]
const std::shared_ptr<Font>&
GetFont() const noexcept {
190 return mCurrentState.blend_mode;
196 void DrawLine(
float x1,
float y1,
float x2,
float y2);
240 void DrawArc(
float cx,
float cy,
float rx,
float ry,
float start_degrees,
241 float sweep_degrees);
244 void DrawPie(
float cx,
float cy,
float rx,
float ry,
float start_degrees,
245 float sweep_degrees);
248 void FillPie(
float cx,
float cy,
float rx,
float ry,
float start_degrees,
249 float sweep_degrees);
252 void DrawChord(
float cx,
float cy,
float rx,
float ry,
float start_degrees,
253 float sweep_degrees);
256 void FillChord(
float cx,
float cy,
float rx,
float ry,
float start_degrees,
257 float sweep_degrees);
276 const Color& tint = Color::White(),
277 ImageFlip flip = ImageFlip::kNone);
281 const Color& tint = Color::White(),
282 ImageFlip flip = ImageFlip::kNone);
302 const std::vector<Point>& points,
303 const Color& tint = Color::White());
330 const Rect& dest_rect,
const Color& tint = Color::White(),
331 ImageFlip flip = ImageFlip::kNone);
340 void DrawText(
float x,
float y,
const std::string& text);
353 Alignment alignment = Alignment::kLeft,
354 TextWrap wrap = TextWrap::kNone);
364 TextWrap wrap)
const;
400 void QueryDrawableSize(int32_t& out_width, int32_t& out_height)
const;
403 void ApplyDrawableSize(int32_t width, int32_t height);
406 void UpdateProjection();
410 void PushStroke(
const std::vector<Vertex>& verts,
const Color& color);
416 void PushFilled(std::vector<Vertex>& verts);
422 void DrawTextLine(
float x,
float y,
const std::string& text);
425 [[nodiscard]]
float AlignedX(
const Rect& rect,
const std::string& line,
426 Alignment alignment)
const;
431 void ApplyScissor(
const Rect& rect);
434 void ClearScissorCounted();
436 [[nodiscard]]
bool CanDrawPen() const noexcept {
437 return mRenderer && mBatcher && mCurrentState.pen.IsVisible();
439 [[nodiscard]]
bool CanDrawBrush() const noexcept {
440 return mRenderer && mBatcher && mCurrentState.brush.IsVisible();
443 SDL_Window* mWindow{
nullptr};
445 std::unique_ptr<IRenderer> mRenderer;
446 std::unique_ptr<RenderBatcher> mBatcher;
447 std::vector<RenderState> mStateStack;
448 RenderState mCurrentState;
449 std::shared_ptr<Font> mCurrentFont;
453 FrameStats mLastStats;
454 uint64_t mFrameStartNs{0};
457 int32_t mDrawableWidth{0};
458 int32_t mDrawableHeight{0};
463 int32_t mViewportX{0};
464 int32_t mViewportY{0};
465 int32_t mViewportWidth{0};
466 int32_t mViewportHeight{0};
470 bool mCustomViewport{
false};
474 bool mAutoDrawableSize{
true};
Dolgu stili — düz renk veya gradient.
Definition brush.h:34
Backend-agnostik soyut renderer arayüzü.
Definition renderer.h:64
Yüklenmiş görüntü — texture sarmalayıcı.
Definition image.h:39
void DrawPolygon(const std::vector< Point > &points)
Çok kenarlı kapalı şeklin çerçevesini çiz.
void ClearClip()
Kırpma dikdörtgenini kaldır.
void DrawChord(float cx, float cy, float rx, float ry, float start_degrees, float sweep_degrees)
Kiriş (chord) çerçevesi — yay artı uçlarını birleştiren doğru.
void FillPie(float cx, float cy, float rx, float ry, float start_degrees, float sweep_degrees)
Dilimi doldur. Çizelgelerin (pasta grafik) temel yapı taşı.
void SetBrush(const Brush &brush)
Aktif fırçayı ayarla (dolgu rengi).
void Translate(float dx, float dy)
Öteleme uygula.
void Begin()
Frame başlangıcı — her frame başında çağrılmalı.
Painter(std::unique_ptr< IRenderer > renderer, int32_t viewport_width, int32_t viewport_height)
Hazır bir renderer ile pencere olmadan Painter oluştur.
void End()
Frame sonu — her frame sonunda çağrılmalı, ekrana sunar.
void DrawImage(const Image &image, const Rect &src_rect, const Rect &dest_rect, const Color &tint=Color::White(), ImageFlip flip=ImageFlip::kNone)
Görüntünün kaynak dikdörtgenini hedef dikdörtgene çiz.
void UpdateImage(const Image &image, const uint8_t *rgba)
Yüklenmiş bir görüntünün doku içeriğini yerinde güncelle.
void DrawPolyline(const std::vector< Point > &points)
Açık çizgi dizisi çiz.
void DrawEllipse(float cx, float cy, float rx, float ry)
Elips çerçeve çiz.
const std::shared_ptr< Font > & GetFont() const noexcept
Aktif font (yoksa nullptr).
Definition painter.h:170
void Restore()
Son kaydedilen durumu geri yükle.
void Save()
Mevcut render durumunu stack'e kaydet.
void FillRoundedRect(float x, float y, float w, float h, float radius)
Yuvarlatılmış köşeli dikdörtgeni doldur.
void SetOpacity(float alpha)
Global opaklığı ayarla [0.0, 1.0].
const FrameStats & GetFrameStats() const noexcept
Son tamamlanan karenin çizim istatistikleri.
Definition painter.h:150
void DrawImage(const Image &image, const Rect &dest_rect, const Color &tint=Color::White(), ImageFlip flip=ImageFlip::kNone)
Görüntüyü hedef dikdörtgene ölçekleyerek çiz.
void DrawCircle(float cx, float cy, float radius)
Daire çerçeve çiz.
void ResetTransform()
Transform'u birim matrise sıfırla.
void Clear(const Color &color)
Ekranı belirtilen renkle temizle.
std::size_t CountTextLines(const std::string &text, float max_width, TextWrap wrap) const
Sarmalanmış metnin kaç satır tutacağını hesapla (çizmeden).
void DrawImage(const Image &image, float x, float y, const Color &tint=Color::White(), ImageFlip flip=ImageFlip::kNone)
Görüntüyü orijinal boyutuyla çiz.
void SetViewport(int32_t x, int32_t y, int32_t width, int32_t height)
Çizimi pencerenin bir alt dikdörtgeniyle sınırla.
void DrawRoundedRect(float x, float y, float w, float h, float radius)
Yuvarlatılmış köşeli dikdörtgen çerçevesi çiz.
BlendMode GetBlendMode() const noexcept
Yürürlükteki karıştırma modu.
Definition painter.h:189
void DrawArc(float cx, float cy, float rx, float ry, float start_degrees, float sweep_degrees)
Yay çiz (açık — uçları birleştirilmez).
Painter(SDL_Window *window, RendererBackend backend)
Belirtilen pencere ve backend ile Painter oluştur.
void SetClipRect(const Rect &rect)
Scissor kırpma dikdörtgeni ayarla.
void DrawText(const Rect &rect, const std::string &text, Alignment alignment=Alignment::kLeft, TextWrap wrap=TextWrap::kNone)
Dikdörtgen içine hizalanmış metin çiz.
void FillPolygon(const std::vector< Point > &points)
Çok kenarlıyı doldur (ear clipping tessellation).
void ResetViewport()
Viewport'u tüm çizim yüzeyine geri al.
void DrawImageMesh(const Image &image, int32_t cols, int32_t rows, const std::vector< Point > &points, const Color &tint=Color::White())
Dokuyu serbest biçimli bir ızgara üzerine çiz.
void SetPen(const Pen &pen)
Aktif kalemi ayarla (çizgi rengi ve kalınlığı).
void Scale(float sx, float sy)
Ölçekleme uygula.
void DrawPie(float cx, float cy, float rx, float ry, float start_degrees, float sweep_degrees)
Dilim (pie) çerçevesi — yay artı merkeze giden iki yarıçap.
void DrawLine(float x1, float y1, float x2, float y2)
İki nokta arasına çizgi çiz.
void FillCircle(float cx, float cy, float radius)
Daireyi doldur.
bool IsValid() const noexcept
Renderer başarıyla başlatıldı mı?
Definition painter.h:88
void FillRect(float x, float y, float w, float h)
Dikdörtgeni doldur.
void SetBlendMode(BlendMode mode)
Renk karıştırma modunu ayarla.
void FillEllipse(float cx, float cy, float rx, float ry)
Elipsi doldur.
void DrawText(float x, float y, const std::string &text)
Noktaya metin çiz.
void FillChord(float cx, float cy, float rx, float ry, float start_degrees, float sweep_degrees)
Kirişi doldur.
void DrawRect(float x, float y, float w, float h)
Dikdörtgen çerçeve çiz (dolgu yok).
void SetDrawableSize(int32_t width, int32_t height)
Çizim yüzeyi boyutunu bildir (viewport + projeksiyon güncellenir).
void SetFont(std::shared_ptr< Font > font)
Aktif fontu ayarla.
void Rotate(float angle_degrees)
Döndürme uygula (derece).
Çizgi stili — renk, kalınlık ve isteğe bağlı dış kontur.
Definition pen.h:49
RGBA renk temsili. Her kanal [0, 255] aralığında.
Definition color.h:8
Bir karenin çizim maliyeti — profilleme ve ekran üstü gösterim için.
Definition frame_stats.h:16
2B dikdörtgen — sol üst köşe + genişlik/yükseklik.
Definition geometry.h:34
Aktif render durumu — transform stack elemanı.
Definition painter.h:37
glm::mat3 transform
3x3 affine dönüşüm (column-major, birim).
Definition painter.h:38