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
15 changes: 8 additions & 7 deletions Library/PAX_GRAPHICA/Circle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
#include <PAX_GRAPHICA/SFML_Circle.hpp>
#endif

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

#include <PAX_SAPIENTICA/Core/Type/Vector2.hpp>

namespace paxg {

struct Circle
{
#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 paxg::Vec2i& pos, const float r) : circle(pos.x(), pos.y(), r) {}
constexpr Circle(const paxg::Vec2<double>& pos, const float r) : circle(static_cast<float>(pos.x()), static_cast<float>(pos.y()), r) {}
constexpr Circle(const paxs::Vector2<int>& pos, const float r) : circle(pos.x, pos.y, r) {}
constexpr Circle(const paxs::Vector2<float>& pos, const float r) : circle(pos.x, pos.y, r) {}
constexpr Circle(const paxs::Vector2<double>& pos, const float r) : circle(static_cast<float>(pos.x), static_cast<float>(pos.y), r) {}
constexpr operator s3d::Circle() 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 paxg::Vec2i& pos, const float r) : x(static_cast<float>(pos.x())), y(static_cast<float>(pos.y())), r(r) {}
constexpr Circle(const paxg::Vec2<double>& pos, const float r) : x(static_cast<float>(pos.x())), y(static_cast<float>(pos.y())), r(r) {}
constexpr Circle(const paxs::Vector2<int>& pos, const float r) : x(static_cast<float>(pos.x)), y(static_cast<float>(pos.y)), r(r) {}
constexpr Circle(const paxs::Vector2<float>& pos, const float r) : x(pos.x), y(pos.y), r(r) {}
constexpr Circle(const paxs::Vector2<double>& pos, const float r) : x(static_cast<float>(pos.x)), y(static_cast<float>(pos.y)), r(r) {}
#endif
void draw() const {
#if defined(PAXS_USING_SIV3D)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <DxLib.h>

#include <PAX_GRAPHICA/Image.hpp>
#include <PAX_GRAPHICA/TextureImpl.hpp>
#include <PAX_GRAPHICA/Interface/TextureImpl.hpp>

#include <PAX_SAPIENTICA/System/AppConfig.hpp>
#include <PAX_SAPIENTICA/Utility/Logger.hpp>
Expand Down Expand Up @@ -115,28 +115,28 @@ namespace paxg {
DxLib::DrawGraph(0, 0, texture, TRUE);
}

void drawAt(const Vec2f& pos) const override {
void drawAt(const paxs::Vector2<int>& pos) const override {
DxLib::DrawGraph(
static_cast<int>(pos.x() - (cachedWidth / 2.0f)),
static_cast<int>(pos.y() - (cachedHeight / 2.0f)),
pos.x - (cachedWidth / 2),
pos.y - (cachedHeight / 2),
texture, TRUE);
}

void drawAt(const Vec2i& pos) const override {
void drawAt(const paxs::Vector2<float>& pos) const override {
DxLib::DrawGraph(
pos.x() - (cachedWidth / 2),
pos.y() - (cachedHeight / 2),
static_cast<int>(pos.x - (cachedWidth / 2.0f)),
static_cast<int>(pos.y - (cachedHeight / 2.0f)),
texture, TRUE);
}

void resizedDrawAt(const Vec2i& resize, const Vec2i& pos) const override {
void resizedDraw(const paxs::Vector2<int>& resize, const paxs::Vector2<int>& pos) const override {
DxLib::DrawExtendGraph(
pos.x() - (resize.x() / 2), pos.y() - (resize.y() / 2),
pos.x() + (resize.x() / 2), pos.y() + (resize.y() / 2),
pos.x, pos.y,
pos.x + resize.x, pos.y + resize.y,
texture, TRUE);
}

void resizedDrawAt(int resize, const Vec2i& pos) const override {
void resizedDraw(int resize, const paxs::Vector2<int>& pos) const override {
// アスペクト比を維持して 'resize x resize' に収めるスケールを計算
const float scale_x = static_cast<float>(resize) / cachedWidth;
const float scale_y = static_cast<float>(resize) / cachedHeight;
Expand All @@ -146,45 +146,30 @@ namespace paxg {
const int new_height = static_cast<int>(cachedHeight * scale);

DxLib::DrawExtendGraph(
pos.x() - (new_width / 2), pos.y() - (new_height / 2),
pos.x() + (new_width / 2), pos.y() + (new_height / 2),
pos.x, pos.y,
pos.x + new_width, pos.y + new_height,
texture, TRUE);
}

void resizedDrawAt(const Vec2f& resize, const Vec2f& pos) const override {
void resizedDraw(const paxs::Vector2<float>& resize, const paxs::Vector2<float>& pos) const override {
DxLib::DrawExtendGraph(
static_cast<int>(pos.x() - (resize.x() / 2)),
static_cast<int>(pos.y() - (resize.y() / 2)),
static_cast<int>(pos.x() + (resize.x() / 2)),
static_cast<int>(pos.y() + (resize.y() / 2)),
static_cast<int>(pos.x), static_cast<int>(pos.y),
static_cast<int>(pos.x + resize.x), static_cast<int>(pos.y + resize.y),
texture, TRUE);
}

void resizedDrawAt(int resize, const Vec2f& pos) const override {
// アスペクト比を維持して 'resize x resize' に収めるスケールを計算
const float scale_x = static_cast<float>(resize) / cachedWidth;
const float scale_y = static_cast<float>(resize) / cachedHeight;
const float scale = (scale_x < scale_y) ? scale_x : scale_y;

const float new_width = cachedWidth * scale;
const float new_height = cachedHeight * scale;

DxLib::DrawExtendGraph(
static_cast<int>(pos.x() - (new_width / 2.0f)),
static_cast<int>(pos.y() - (new_height / 2.0f)),
static_cast<int>(pos.x() + (new_width / 2.0f)),
static_cast<int>(pos.y() + (new_height / 2.0f)),
texture, TRUE);
void resizedDraw(int resize, const paxs::Vector2<float>& pos) const override {
resizedDraw(resize, paxs::Vector2<int>(pos));
}

void resizedDraw(const Vec2i& resize, const Vec2i& pos) const override {
void resizedDrawAt(const paxs::Vector2<int>& resize, const paxs::Vector2<int>& pos) const override {
DxLib::DrawExtendGraph(
pos.x(), pos.y(),
pos.x() + resize.x(), pos.y() + resize.y(),
pos.x - (resize.x / 2), pos.y - (resize.y / 2),
pos.x + (resize.x / 2), pos.y + (resize.y / 2),
texture, TRUE);
}

void resizedDraw(int resize, const Vec2i& pos) const override {
void resizedDrawAt(int resize, const paxs::Vector2<int>& pos) const override {
// アスペクト比を維持して 'resize x resize' に収めるスケールを計算
const float scale_x = static_cast<float>(resize) / cachedWidth;
const float scale_y = static_cast<float>(resize) / cachedHeight;
Expand All @@ -194,31 +179,22 @@ namespace paxg {
const int new_height = static_cast<int>(cachedHeight * scale);

DxLib::DrawExtendGraph(
pos.x(), pos.y(),
pos.x() + new_width, pos.y() + new_height,
pos.x - (new_width / 2), pos.y - (new_height / 2),
pos.x + (new_width / 2), pos.y + (new_height / 2),
texture, TRUE);
}

void resizedDraw(const Vec2f& resize, const Vec2f& pos) const override {
void resizedDrawAt(const paxs::Vector2<float>& resize, const paxs::Vector2<float>& pos) const override {
DxLib::DrawExtendGraph(
static_cast<int>(pos.x()), static_cast<int>(pos.y()),
static_cast<int>(pos.x() + resize.x()), static_cast<int>(pos.y() + resize.y()),
static_cast<int>(pos.x - (resize.x / 2)),
static_cast<int>(pos.y - (resize.y / 2)),
static_cast<int>(pos.x + (resize.x / 2)),
static_cast<int>(pos.y + (resize.y / 2)),
texture, TRUE);
}

void resizedDraw(int resize, const Vec2f& pos) const override {
// アスペクト比を維持して 'resize x resize' に収めるスケールを計算
const float scale_x = static_cast<float>(resize) / cachedWidth;
const float scale_y = static_cast<float>(resize) / cachedHeight;
const float scale = (scale_x < scale_y) ? scale_x : scale_y;

const float new_width = cachedWidth * scale;
const float new_height = cachedHeight * scale;

DxLib::DrawExtendGraph(
static_cast<int>(pos.x()), static_cast<int>(pos.y()),
static_cast<int>(pos.x() + new_width), static_cast<int>(pos.y() + new_height),
texture, TRUE);
void resizedDrawAt(int resize, const paxs::Vector2<float>& pos) const override {
resizedDrawAt(resize, paxs::Vector2<int>(pos));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <Windows.h>
#endif // PAXS_PLATFORM_WINDOWS

#include <PAX_GRAPHICA/WindowImpl.hpp>
#include <PAX_GRAPHICA/Interface/WindowImpl.hpp>

#include <PAX_SAPIENTICA/System/AppConfig.hpp>
#include <PAX_SAPIENTICA/System/AppConst.hpp>
Expand Down Expand Up @@ -131,11 +131,7 @@ namespace paxg {
cacheDirty = false;
}

void setPosition(int, int) override {
// DxLib does not support window position control
}

void setPosition(const Vec2i&) override {
void setPosition(const paxs::Vector2<int>&) override {
// DxLib does not support window position control
}

Expand Down Expand Up @@ -179,26 +175,14 @@ namespace paxg {
// DxLib does not support mouse cursor visibility control
}

void setMouseCursorGrabbed(bool) override {
// DxLib does not support mouse cursor grabbing
}

void setMouseCursor(const std::string&) override {
// DxLib does not support mouse cursor setting
}

void setMousePosition(int, int) override {
void setMousePosition(const paxs::Vector2<int>&) override {
// DxLib does not support mouse position setting
}

void setMousePosition(const Vec2i&) override {
// DxLib does not support mouse position setting
}

void setKeyRepeat(bool) override {
// DxLib does not support key repeat control
}

void setBackgroundColor(const Color color) override {
DxLib::SetBackgroundColor(color.r, color.g, color.b);
}
Expand All @@ -215,9 +199,9 @@ namespace paxg {
DxLib::SetWindowStyleMode(decorated ? 1 : 8); // 1: 通常ウィンドウ, 8: 枠なし
}

Vec2i center() const override {
paxs::Vector2<int> center() const override {
updateCache();
return Vec2i{cachedWidth / 2, cachedHeight / 2};
return paxs::Vector2<int>{cachedWidth / 2, cachedHeight / 2};
}

int width() const override {
Expand All @@ -230,14 +214,14 @@ namespace paxg {
return cachedHeight;
}

Vec2i size() const override {
paxs::Vector2<int> size() const override {
updateCache();
return Vec2i{cachedWidth, cachedHeight};
return paxs::Vector2<int>{cachedWidth, cachedHeight};
}

Vec2i getMousePosition() const override {
paxs::Vector2<int> getMousePosition() const override {
// DxLib does not support mouse position query
return Vec2i(0, 0);
return paxs::Vector2<int>(0, 0);
}

bool hasFocus() const override {
Expand All @@ -259,6 +243,6 @@ namespace paxg {

} // namespace paxg

#endif // defined(PAXS_USING_DXLIB)
#endif // PAXS_USING_DXLIB

#endif // !PAX_GRAPHICA_DXLIB_WINDOW_IMPL_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <string>

#include <PAX_GRAPHICA/String.hpp>
#include <PAX_GRAPHICA/Vec2.hpp>

#include <PAX_SAPIENTICA/Core/Type/Vector2.hpp>
#include <PAX_SAPIENTICA/Utility/StringUtils.hpp>

namespace paxg {
Expand All @@ -31,18 +31,19 @@ namespace paxg {
virtual int height() const = 0;

virtual void draw() const = 0;
virtual void drawAt(const paxg::Vec2f& pos) const = 0;
virtual void drawAt(const paxg::Vec2i& pos) const = 0;

virtual void resizedDrawAt(const paxg::Vec2i& resize, const paxg::Vec2i& pos) const = 0;
virtual void resizedDrawAt(int resize, const paxg::Vec2i& pos) const = 0;
virtual void resizedDrawAt(const paxg::Vec2f& resize, const paxg::Vec2f& pos) const = 0;
virtual void resizedDrawAt(int resize, const paxg::Vec2f& pos) const = 0;

virtual void resizedDraw(const paxg::Vec2i& resize, const paxg::Vec2i& pos) const = 0;
virtual void resizedDraw(int resize, const paxg::Vec2i& pos) const = 0;
virtual void resizedDraw(const paxg::Vec2f& resize, const paxg::Vec2f& pos) const = 0;
virtual void resizedDraw(int resize, const paxg::Vec2f& pos) const = 0;

virtual void drawAt(const paxs::Vector2<int>& pos) const = 0;
virtual void drawAt(const paxs::Vector2<float>& pos) const = 0;

virtual void resizedDraw(const paxs::Vector2<int>& resize, const paxs::Vector2<int>& pos) const = 0;
virtual void resizedDraw(int resize, const paxs::Vector2<int>& pos) const = 0;
virtual void resizedDraw(const paxs::Vector2<float>& resize, const paxs::Vector2<float>& pos) const = 0;
virtual void resizedDraw(int resize, const paxs::Vector2<float>& pos) const = 0;

virtual void resizedDrawAt(const paxs::Vector2<int>& resize, const paxs::Vector2<int>& pos) const = 0;
virtual void resizedDrawAt(int resize, const paxs::Vector2<int>& pos) const = 0;
virtual void resizedDrawAt(const paxs::Vector2<float>& resize, const paxs::Vector2<float>& pos) const = 0;
virtual void resizedDrawAt(int resize, const paxs::Vector2<float>& pos) const = 0;

protected:
// Helper to convert SVG paths to PNG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <string>

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

#include <PAX_SAPIENTICA/Core/Type/Vector2.hpp>

namespace paxg {

Expand All @@ -36,28 +37,24 @@ namespace paxg {

virtual void setTitle(const std::string& title) = 0;
virtual void setSize(int width, int height) = 0;
virtual void setPosition(int x, int y) = 0;
virtual void setPosition(const Vec2i& pos) = 0;
virtual void setPosition(const paxs::Vector2<int>& pos) = 0;
virtual void setIcon(const std::string& path) = 0;
virtual void setVisible(bool visible) = 0;
virtual void setVSync(bool vsync) = 0;
virtual void setFPS(int fps) = 0;
virtual void setMouseCursorVisible(bool visible) = 0;
virtual void setMouseCursorGrabbed(bool grabbed) = 0;
virtual void setMouseCursor(const std::string& path) = 0;
virtual void setMousePosition(int x, int y) = 0;
virtual void setMousePosition(const Vec2i& pos) = 0;
virtual void setKeyRepeat(bool repeat) = 0;
virtual void setBackgroundColor(const paxg::Color color) = 0;
virtual void setLetterbox(const paxg::Color color) = 0;
virtual void setMousePosition(const paxs::Vector2<int>& pos) = 0;
virtual void setBackgroundColor(paxg::Color color) = 0;
virtual void setLetterbox(paxg::Color color) = 0;
virtual void setResizable(bool resizable) = 0;
virtual void setDecorated(bool decorated) = 0;

virtual paxg::Vec2i center() const = 0;
virtual paxs::Vector2<int> center() const = 0;
virtual int width() const = 0;
virtual int height() const = 0;
virtual paxg::Vec2i size() const = 0;
virtual paxg::Vec2i getMousePosition() const = 0;
virtual paxs::Vector2<int> size() const = 0;
virtual paxs::Vector2<int> getMousePosition() const = 0;
virtual bool hasFocus() const = 0;

virtual void clear() = 0;
Expand Down
Loading