Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .github/workflows/cmake-all-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
sudo apt-get clean
sudo apt-get update
sudo apt-get install libopencv-dev
sudo apt-get install libsfml-dev
sudo apt-get install cmake
sudo apt-get install g++

Expand Down
17 changes: 10 additions & 7 deletions Library/PAX_GRAPHICA/Circle.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*##########################################################################################
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

Expand All @@ -20,9 +20,12 @@
#include <Siv3D.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics.hpp>
#elif defined(PAXS_USING_DXLIB)
#include <DxLib.h>
#endif

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

namespace paxg {
Expand All @@ -32,17 +35,17 @@ namespace paxg {
#if defined(PAXS_USING_SIV3D)
s3d::Circle circle;
constexpr Circle(const float x, const float y, const float r) : circle(x, y, r) {}
constexpr Circle(const Vec2& pos, const float r) : circle(pos.x, pos.y, r) {}
constexpr Circle(const paxg::Vec2i& pos, const float r) : circle(pos.x(), pos.y(), r) {}
constexpr 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); }
Circle(const float x, const float y, const float r) : circle(r) { circle.setPosition(x, y); }
Circle(const sf::Vector2i& pos, const float r) : circle(r) { circle.setPosition(pos.x, pos.y); }
operator sf::CircleShape() const { return circle; }
#else
float x, y, r;
constexpr Circle(const float x, const float y, const float r) : x(x), y(y), r(r) {}
constexpr Circle(const Vec2& pos, const float r) : x(pos.x), y(pos.y), r(r) {}
constexpr Circle(const paxg::Vec2i& pos, const float r) : x(static_cast<float>(pos.x())), y(static_cast<float>(pos.y())), r(r) {}
#endif
void draw() const override {
#if defined(PAXS_USING_SIV3D)
Expand All @@ -52,8 +55,8 @@ namespace paxg {
#endif
}

void drawAt(const Vec2f& pos) const override {}
void drawAt([[maybe_unused]] const Vec2f& pos) const override {}
};
}

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

PAX SAPIENTICA Library 💀🌿🌏

Expand All @@ -20,25 +20,35 @@
#include <Siv3D/Color.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics/Color.hpp>
#elif defined(PAXS_USING_DXLIB)
#include <DxLib.h>
#endif

namespace paxg {

// R 赤
// G 緑
// B 青
// A 不透明度
struct Color {
#if defined(PAXS_USING_SIV3D)
s3d::Color color;
constexpr Color(const int r, const int g, const int b, const int a) : color(r, g, b, a) {}
constexpr s3d::Color() const { return color; }
constexpr Color(const int r, const int g, const int b, const int a = 255) :
color(static_cast<s3d::Color::value_type>(r),
static_cast<s3d::Color::value_type>(g),
static_cast<s3d::Color::value_type>(b),
static_cast<s3d::Color::value_type>(a)) {}
operator s3d::Color() const { return color; }
#elif defined(PAXS_USING_SFML)
sf::Color color;
Color(const int r, const int g, const int b, const int a) : color(r, g, b, a) {}
Color(const int r, const int g, const int b, const int a = 255) : color(r, g, b, a) {}
operator sf::Color() const { return color; }
#else
int r, g, b, a;
constexpr Color(int r, int g, int b, int a) : r(r), g(g), b(b), a(a) {}
int r, g, b, a = 255;
constexpr Color(int r, int g, int b, int a = 255) : r(r), g(g), b(b), a(a) {}
#endif
};

}

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

PAX SAPIENTICA Library 💀🌿🌏

Expand All @@ -21,4 +21,4 @@
#include <PAX_GRAPHICA/Texture.hpp>
#include <PAX_GRAPHICA/Window.hpp>

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

PAX SAPIENTICA Library 💀🌿🌏

Expand Down Expand Up @@ -27,8 +27,9 @@ namespace paxg {
virtual void draw() const = 0;

virtual void drawAt(const Vec2f& pos) const = 0;
virtual void drawAt(const Vec2i& pos) const = 0;
};

}

#endif // !PAX_GRAPHICA_IDRAWABLE_HPP
#endif // !PAX_GRAPHICA_IDRAWABLE_HPP
10 changes: 6 additions & 4 deletions Library/PAX_GRAPHICA/Image.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*##########################################################################################
/*##########################################################################################

PAX SAPIENTICA Library 💀🌿🌏

Expand All @@ -20,6 +20,8 @@
#include <Siv3D.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics.hpp>
#elif defined(PAXS_USING_DXLIB)
#include <DxLib.h>
#endif

#include <PAX_GRAPHICA/String.hpp>
Expand All @@ -30,16 +32,16 @@ namespace paxg {
{
#if defined(PAXS_USING_SIV3D)
s3d::Image image;
constexpr Image(const paxg::String& path) : image(path) {}
Image(const paxg::String& path) : image(path.string) {}
constexpr operator s3d::Image() const { return image; }
#elif defined(PAXS_USING_SFML)
sf::Image image;
Image(const paxg::String& path) { image.loadFromFile(path); }
operator sf::Image() const { return image; }
#else
constexpr Image(const paxg::String& path) {}
constexpr Image([[maybe_unused]] const paxg::String& path) {}
#endif
};
}

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

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_LINE_HPP
#define PAX_GRAPHICA_LINE_HPP

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

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

#if defined(PAXS_USING_SIV3D)
#include <Siv3D.hpp>
#elif defined(PAXS_USING_SFML)
#include <SFML/Graphics.hpp>
#elif defined(PAXS_USING_DXLIB)
#include <DxLib.h>
#endif

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

namespace paxg {

struct Line {
constexpr Line() = default;
#if defined(PAXS_USING_SIV3D)
s3d::Line line{};
constexpr Line(const float sx, const float sy, const float ex, const float ey)
: line(sx, sy, ex, ey) {}
constexpr Line(const float sx, const float sy, const Vec2i& e)
: line(sx, sy, e.x(), e.y()) {}
constexpr Line(const Vec2i& s, const Vec2i& e)
: line(s.x(), s.y(), e.x(), e.y()) {}

void draw(const double thickness, const paxg::Color& color) const {
line.draw(thickness, color.color);
}
#elif defined(PAXS_USING_DXLIB)
float x0{}, y0{}, w0{}, h0{};
constexpr Line(const float x, const float y, const float w, const float h) :
x0(x), y0(y), w0(w), h0(h) {}
constexpr Line(const Vec2i& pos, const Vec2i& size)
: x0(static_cast<float>(pos.x())), y0(static_cast<float>(pos.y())),
w0(static_cast<float>(size.x())), h0(static_cast<float>(size.y())) {}
constexpr Line(const Vec2i& pos, const float w, const float h) :
x0(static_cast<float>(pos.x())), y0(static_cast<float>(pos.y())), w0(w), h0(h) {}
constexpr Line(const float x, const float y, const Vec2i& size)
: x0(x), y0(y), w0(static_cast<float>(size.x())), h0(static_cast<float>(size.y())) {}

void draw(const double thickness, const paxg::Color& color) const {
// 直線の場合
if (y0 == h0 || x0 == w0) {
const int x1 = static_cast<int>(x0 - thickness / 2);
const int y1 = static_cast<int>(y0 - thickness / 2);
const int w1 = static_cast<int>(w0 + thickness / 2);
const int h1 = static_cast<int>(h0 + thickness / 2);

DxLib::DrawBox(
x1,
y1,
(w1 == x1) ? w1 + 1 : w1,
(h1 == y1) ? h1 + 1 : h1,
DxLib::GetColor(color.r, color.g, color.b), TRUE);
}
}
#else
float sx0{}, sy0{}, ex0{}, ey0{};
constexpr Line(const float sx, const float sy, const float ex, const float ey)
: sx0(sx), sy0(sy), ex0(ex), ey0(ey) {}
constexpr Line(const float sx, const float sy, const Vec2i& e)
: sx0(sx), sy0(sy), ex0(static_cast<float>(e.x())), ey0(static_cast<float>(e.y())) {}
constexpr Line(const Vec2i& s, const Vec2i& e)
: sx0(static_cast<float>(s.x())), sy0(static_cast<float>(s.y())),
ex0(static_cast<float>(e.x())), ey0(static_cast<float>(e.y())) {}

void draw([[maybe_unused]] const double thickness, [[maybe_unused]] const paxg::Color& color) const {
}
#endif
};
}

#endif // !PAX_GRAPHICA_RECT_HPP
Loading