Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Library/PAX_GRAPHICA/Circle.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/

##########################################################################################*/

#ifndef PAX_GRAPHICA_CIRCLE_HPP
#define PAX_GRAPHICA_CIRCLE_HPP

/*##########################################################################################

##########################################################################################*/

#ifdef PAXS_USING_SIV3D
#include <Siv3D.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics.hpp>
#endif

#include <PAX_GRAPHICA/IDrawable.hpp>
#include <PAX_GRAPHICA/Window.hpp>

namespace paxg {

struct Circle : public IDrawable
{
#ifdef PAXS_USING_SIV3D
s3d::Circle circle;
Circle(float x, float y, float r) : circle(x, y, r) {}
Circle(const Vec2& pos, float r) : circle(pos.x, pos.y, r) {}
operator s3d::Circle() const { return circle; }
#elif defined(PAXS_USING_SFML)
sf::CircleShape circle;
Circle(float x, float y, float r) : circle(r) { circle.setPosition(x, y); }
Circle(const sf::Vector2i& pos, float r) : circle(r) { circle.setPosition(pos.x, pos.y); }
operator sf::CircleShape() const { return circle; }
#else
float x, y, r;
Circle(float x, float y, float r) : x(x), y(y), r(r) {}
Circle(const Vec2& pos, float r) : x(pos.x), y(pos.y), r(r) {}
#endif
void draw() const override {
#ifdef PAXS_USING_SIV3D
circle.draw();
#elif defined(PAXS_USING_SFML)
Window::window.draw(circle);
#endif
}

void drawAt(const Vec2& pos) const override {}
};
}

#endif // !PAX_GRAPHICA_CIRCLE_HPP
44 changes: 44 additions & 0 deletions Library/PAX_GRAPHICA/Color.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/

##########################################################################################*/

#ifndef PAX_GRAPHICA_COLOR_HPP
#define PAX_GRAPHICA_COLOR_HPP

/*##########################################################################################

##########################################################################################*/

#ifdef PAXS_USING_SIV3D
#include <Siv3D/Color.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics/Color.hpp>
#endif

namespace paxg {

struct Color {
#ifdef PAXS_USING_SIV3D
s3d::Color color;
Color(int r, int g, int b, int a) : color(r, g, b, a) {}
s3d::Color() const { return color; }
#elif defined(PAXS_USING_SFML)
sf::Color color;
Color(int r, int g, int b, int a) : color(r, g, b, a) {}
operator sf::Color() const { return color; }
#else
int r, g, b, a;
Color(int r, int g, int b, int a) : r(r), g(g), b(b), a(a) {}
#endif
};

}

#endif // !PAX_GRAPHICA_COLOR_HPP
23 changes: 23 additions & 0 deletions Library/PAX_GRAPHICA/Graphics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/

##########################################################################################*/

#ifndef PAX_GRAPHICA_GRAPHICS_HPP
#define PAX_GRAPHICA_GRAPHICS_HPP

/*##########################################################################################

##########################################################################################*/

#include <PAX_GRAPHICA/Circle.hpp>
#include <PAX_GRAPHICA/Rect.hpp>
#include <PAX_GRAPHICA/Window.hpp>

#endif // !PAX_GRAPHICA_GRAPHICS_HPP
34 changes: 34 additions & 0 deletions Library/PAX_GRAPHICA/IDrawable.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/

##########################################################################################*/

#ifndef PAX_GRAPHICA_IDRAWABLE_HPP
#define PAX_GRAPHICA_IDRAWABLE_HPP

/*##########################################################################################

##########################################################################################*/

#include <PAX_GRAPHICA/Vec2.hpp>

namespace paxg {

struct IDrawable {

virtual ~IDrawable() {}

virtual void draw() const = 0;

virtual void drawAt(const paxg::Vec2& pos) const = 0;
};

}

#endif // !PAX_GRAPHICA_IDRAWABLE_HPP
65 changes: 65 additions & 0 deletions Library/PAX_GRAPHICA/Rect.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/

##########################################################################################*/

#ifndef PAX_GRAPHICA_RECT_HPP
#define PAX_GRAPHICA_RECT_HPP

/*##########################################################################################

##########################################################################################*/

#ifdef PAXS_USING_SIV3D
#include <Siv3D.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics.hpp>
#endif

#include <PAX_GRAPHICA/IDrawable.hpp>
#include <PAX_GRAPHICA/Vec2.hpp>
#include <PAX_GRAPHICA/Window.hpp>

namespace paxg {

struct Rect : public paxg::IDrawable {
#ifdef PAXS_USING_SIV3D
s3d::RectF rect;
Rect(float x, float y, float w, float h) : rect(x, y, w, h) {}
Rect(const Vec2& pos, const Vec2& size) : rect(pos.x, pos.y, size.x, size.y) {}
Rect(const Vec2& pos, float w, float h) : rect(pos.x, pos.y, w, h) {}
Rect(float x, float y, const Vec2& size) : rect(x, y, size.x, size.y) {}
operator s3d::RectF() const { return rect; }
#elif defined(PAXS_USING_SFML)
sf::RectangleShape rect;
Rect(float x, float y, float w, float h) : rect(sf::Vector2f(w, h)) { rect.setPosition(x, y); }
Rect(const sf::Vector2i& pos, const sf::Vector2i& size) : rect(sf::Vector2f(size.x, size.y)) { rect.setPosition(pos.x, pos.y); }
Rect(const sf::Vector2i& pos, float w, float h) : rect(sf::Vector2f(w, h)) { rect.setPosition(pos.x, pos.y); }
Rect(float x, float y, const sf::Vector2i& size) : rect(sf::Vector2f(size.x, size.y)) { rect.setPosition(x, y); }
operator sf::RectangleShape() const { return rect; }
#else
float x, y, w, h;
Rect(float x, float y, float w, float h) : x(x), y(y), w(w), h(h) {}
Rect(const Vec2& pos, const Vec2& size) : x(pos.x), y(pos.y), w(size.x), h(size.y) {}
Rect(const Vec2& pos, float w, float h) : x(pos.x), y(pos.y), w(w), h(h) {}
Rect(float x, float y, const Vec2& size) : x(x), y(y), w(size.x), h(size.y) {}
#endif
void draw() const override {
#ifdef PAXS_USING_SIV3D
rect.draw();
#elif defined(PAXS_USING_SFML)
Window::window.draw(rect);
#endif
}

void drawAt(const Vec2& pos) const override {}
};
}

#endif // !PAX_GRAPHICA_RECT_HPP
45 changes: 45 additions & 0 deletions Library/PAX_GRAPHICA/Vec2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/

##########################################################################################*/

#ifndef PAX_GRAPHICA_VEC2_HPP
#define PAX_GRAPHICA_VEC2_HPP

/*##########################################################################################

##########################################################################################*/

#ifdef PAXS_USING_SIV3D
#include <Siv3D/Vector2D.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/System/Vector2.hpp>
#endif

namespace paxg {

struct Vec2 {
#ifdef PAXS_USING_SIV3D
s3d::Vec2 vec2;
Vec2(int x, int y) : vec2(x, y) {}
Vec2(const s3d::Vec2& vec2) : vec2(vec2) {}
operator s3d::Vec2() const { return vec2; }
#elif defined(PAXS_USING_SFML)
sf::Vector2i vec2;
Vec2(int x, int y) : vec2(x, y) {}
Vec2(const sf::Vector2i& vec2) : vec2(vec2) {}
operator sf::Vector2i() const { return vec2; }
#else
int x, y;
Vec2(int x, int y) : x(x), y(y) {}
#endif
};
}

#endif // !PAX_GRAPHICA_VEC2_HPP
Loading