1+ /* ##########################################################################################
2+
3+ PAX SAPIENTICA Library 💀🌿🌏
4+
5+ [Planning] 2023 As Project
6+ [Production] 2023 As Project
7+ [Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
8+ [License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/
9+
10+ ##########################################################################################*/
11+
12+ #ifndef PAX_GRAPHICA_RECT_HPP
13+ #define PAX_GRAPHICA_RECT_HPP
14+
15+ /* ##########################################################################################
16+
17+ ##########################################################################################*/
18+
19+ #if defined(PAXS_USING_SIV3D)
20+ #include < Siv3D.hpp>
21+ #elif defined(PAXS_USING_SFML)
22+ #include < SFML/Graphics.hpp>
23+ #endif
24+
25+ #include < PAX_GRAPHICA/IDrawable.hpp>
26+ #include < PAX_GRAPHICA/Vec2.hpp>
27+ #include < PAX_GRAPHICA/Window.hpp>
28+
29+ namespace paxg {
30+
31+ struct Rect : public paxg ::IDrawable {
32+ #if defined(PAXS_USING_SIV3D)
33+ s3d::RectF rect;
34+ constexpr (const float x, const float y, const float w, const float h) : rect(x, y, w, h) {}
35+ constexpr Rect (const Vec2& pos, const Vec2& size) : rect(pos.x, pos.y, size.x, size.y) {}
36+ constexpr Rect (const Vec2& pos, const float w, const float h) : rect(pos.x, pos.y, w, h) {}
37+ constexpr Rect (const float x, const float y, const Vec2& size) : rect(x, y, size.x, size.y) {}
38+ constexpr operator s3d::RectF () const { return rect; }
39+ #elif defined(PAXS_USING_SFML)
40+ sf::RectangleShape rect;
41+ Rect (const float x, const float y, const float w, const float h) : rect(sf::Vector2f(w, h)) { rect.setPosition (x, y); }
42+ Rect (const sf::Vector2i& pos, const sf::Vector2i& size) : rect(sf::Vector2f(size.x, size.y)) { rect.setPosition (pos.x , pos.y ); }
43+ Rect (const sf::Vector2i& pos, const float w, const float h) : rect(sf::Vector2f(w, h)) { rect.setPosition (pos.x , pos.y ); }
44+ Rect (const float x, const float y, const sf::Vector2i& size) : rect(sf::Vector2f(size.x, size.y)) { rect.setPosition (x, y); }
45+ operator sf::RectangleShape () const { return rect; }
46+ #else
47+ float x, y, w, h;
48+ constexpr Rect (const float x, const float y, const float w, const float h) : x(x), y(y), w(w), h(h) {}
49+ constexpr Rect (const Vec2& pos, const Vec2& size) : x(pos.x), y(pos.y), w(size.x), h(size.y) {}
50+ constexpr Rect (const Vec2& pos, const float w, const float h) : x(pos.x), y(pos.y), w(w), h(h) {}
51+ constexpr Rect (const float x, const float y, const Vec2& size) : x(x), y(y), w(size.x), h(size.y) {}
52+ #endif
53+ void draw () const override {
54+ #if defined(PAXS_USING_SIV3D)
55+ rect.draw ();
56+ #elif defined(PAXS_USING_SFML)
57+ Window::window.draw (rect);
58+ #endif
59+ }
60+
61+ void drawAt (const Vec2f& pos) const override {}
62+ };
63+ }
64+
65+ #endif // !PAX_GRAPHICA_RECT_HPP
0 commit comments