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
geometry.h
1
#pragma once
2
3
#include <cstdint>
4
5
namespace
sdl_painter {
6
8
struct
Point {
9
float
x{0.0F};
10
float
y{0.0F};
11
12
constexpr
Point() =
default
;
13
constexpr
Point(
float
x_,
float
y_) : x(x_), y(y_) {}
14
15
[[nodiscard]] Point operator+(
const
Point& other)
const
noexcept
{
16
return
{x + other.x, y + other.y};
17
}
18
[[nodiscard]] Point operator-(
const
Point& other)
const
noexcept
{
19
return
{x - other.x, y - other.y};
20
}
21
[[nodiscard]] Point operator*(
float
s)
const
noexcept
{
22
return
{x * s, y * s};
23
}
24
25
[[nodiscard]]
bool
operator==(
const
Point& other)
const
noexcept
{
26
return
x == other.x && y == other.y;
27
}
28
[[nodiscard]]
bool
operator!=(
const
Point& other)
const
noexcept
{
29
return
!(*
this
== other);
30
}
31
};
32
34
struct
Rect {
35
float
x{0.0F};
36
float
y{0.0F};
37
float
w{0.0F};
38
float
h{0.0F};
39
40
constexpr
Rect() =
default
;
41
constexpr
Rect(
float
x_,
float
y_,
float
w_,
float
h_)
42
: x(x_), y(y_), w(w_), h(h_) {}
43
45
[[nodiscard]]
float
Right
() const noexcept {
return
x + w; }
46
48
[[nodiscard]]
float
Bottom
() const noexcept {
return
y + h; }
49
51
[[nodiscard]]
Point
Center
() const noexcept {
52
return
{x + w * 0.5F, y + h * 0.5F};
53
}
54
56
[[nodiscard]]
bool
Contains
(
float
px,
float
py)
const
noexcept
{
57
return
px >= x && px <=
Right
() && py >= y && py <=
Bottom
();
58
}
59
60
[[nodiscard]]
bool
operator==(
const
Rect
& other)
const
noexcept
{
61
return
x == other.x && y == other.y && w == other.w && h == other.h;
62
}
63
[[nodiscard]]
bool
operator!=(
const
Rect& other)
const
noexcept
{
64
return
!(*
this
== other);
65
}
66
};
67
69
struct
Size {
70
float
w{0.0F};
71
float
h{0.0F};
72
73
constexpr
Size() =
default
;
74
constexpr
Size(
float
w_,
float
h_) : w(w_), h(h_) {}
75
76
[[nodiscard]]
bool
operator==(
const
Size& other)
const
noexcept
{
77
return
w == other.w && h == other.h;
78
}
79
[[nodiscard]]
bool
operator!=(
const
Size& other)
const
noexcept
{
80
return
!(*
this
== other);
81
}
82
};
83
84
}
// namespace sdl_painter
sdl_painter::Point
2D nokta — float koordinatlar.
Definition
geometry.h:8
sdl_painter::Rect
2D dikdörtgen — sol üst köşe + genişlik/yükseklik.
Definition
geometry.h:34
sdl_painter::Rect::Bottom
float Bottom() const noexcept
Dikdörtgenin alt kenarının y koordinatı.
Definition
geometry.h:48
sdl_painter::Rect::Right
float Right() const noexcept
Dikdörtgenin sağ kenarının x koordinatı.
Definition
geometry.h:45
sdl_painter::Rect::Center
Point Center() const noexcept
Merkez noktası.
Definition
geometry.h:51
sdl_painter::Rect::Contains
bool Contains(float px, float py) const noexcept
Verilen nokta dikdörtgen içinde mi?
Definition
geometry.h:56
include
sdl_painter
geometry.h
Oluşturan
1.17.0