SDLPainter 1.4.0
SDL3 + OpenGL/Vulkan 2D çizim kütüphanesi
Yüklüyor...
Arıyor...
Eşleşme Yok
path.h
1#pragma once
2
3#include "sdl_painter/export.h"
4#include "sdl_painter/geometry.h"
5
6#include <cstddef>
7#include <cstdint>
8#include <vector>
9
10namespace sdl_painter {
11
17inline constexpr float kDefaultFlatness = 0.25F;
18
23struct SubPath {
25 std::vector<Point> points;
26
31 bool closed{false};
32};
33
66class SDLPAINTER_API Path {
67 public:
69 Path() = default;
70
75 explicit Path(float flatness);
76
81 void MoveTo(float x, float y);
82
84 void MoveTo(const Point& point);
85
90 void LineTo(float x, float y);
91
93 void LineTo(const Point& point);
94
101 void QuadTo(float cx, float cy, float x, float y);
102
104 void QuadTo(const Point& control, const Point& end);
105
116 void CubicTo(float c1x, float c1y, float c2x, float c2y, float x, float y);
117
119 void CubicTo(const Point& control1, const Point& control2, const Point& end);
120
130 void Close();
131
133 void Clear() noexcept;
134
138 [[nodiscard]] bool IsEmpty() const noexcept;
139
141 [[nodiscard]] Point CurrentPoint() const noexcept { return mCurrent; }
142
144 [[nodiscard]] const std::vector<SubPath>& SubPaths() const noexcept {
145 return mSubPaths;
146 }
147
149 [[nodiscard]] float Flatness() const noexcept { return mFlatness; }
150
152 [[nodiscard]] std::size_t PointCount() const noexcept;
153
154 private:
156 void AppendPoint(const Point& point);
157
163 void DropDegenerateSubPath();
164
170 void EnsureStarted();
171
180 [[nodiscard]] int32_t SegmentsForCurve(float second_derivative_bound) const;
181
187 static constexpr int32_t kMaxCurveSegments = 256;
188
189 std::vector<SubPath> mSubPaths;
190
192 Point mCurrent;
193
195 Point mSubPathStart;
196
201 bool mPendingStart{false};
202
203 float mFlatness{kDefaultFlatness};
204};
205
206} // namespace sdl_painter
void MoveTo(float x, float y)
Yeni bir alt yol başlat ve imleci oraya taşı.
void QuadTo(float cx, float cy, float x, float y)
İkinci dereceden (quadratic) Bézier eğrisi ekle.
void LineTo(float x, float y)
İmleçten verilen noktaya doğru parçası ekle.
void Close()
Yürürlükteki alt yolu kapat.
void CubicTo(const Point &control1, const Point &control2, const Point &end)
Üçüncü dereceden (cubic) Bézier eğrisi ekle.
void MoveTo(const Point &point)
Yeni bir alt yol başlat ve imleci oraya taşı.
void LineTo(const Point &point)
İmleçten verilen noktaya doğru parçası ekle.
void Clear() noexcept
Tüm alt yolları sil; tolerans korunur.
Path(float flatness)
Düzleştirme toleransını belirterek boş yol oluştur.
float Flatness() const noexcept
Yürürlükteki düzleştirme toleransı (piksel).
Definition path.h:149
const std::vector< SubPath > & SubPaths() const noexcept
Düzleştirilmiş alt yollar.
Definition path.h:144
void QuadTo(const Point &control, const Point &end)
İkinci dereceden (quadratic) Bézier eğrisi ekle.
void CubicTo(float c1x, float c1y, float c2x, float c2y, float x, float y)
Üçüncü dereceden (cubic) Bézier eğrisi ekle.
Path()=default
Varsayılan toleransla (kDefaultFlatness) boş yol.
std::size_t PointCount() const noexcept
Bu yolun toplam nokta sayısı (tanı ve test için).
bool IsEmpty() const noexcept
Çizilecek hiçbir parça yok mu?
Point CurrentPoint() const noexcept
Yürürlükteki imleç konumu (yol boşsa orijin).
Definition path.h:141
2B nokta — float koordinatlar.
Definition geometry.h:8
Bir Path içindeki tek parça — düzleştirilmiş nokta dizisi.
Definition path.h:23
std::vector< Point > points
Parçanın noktaları (en az bir tane).
Definition path.h:25
bool closed
Path::Close ile kapatıldı mı?
Definition path.h:31