Improve usage of Line types

This commit is contained in:
jaby 2024-01-05 22:56:44 -06:00
parent 1f38bd9f68
commit 9c6778d497
3 changed files with 45 additions and 8 deletions

View File

@ -7,10 +7,12 @@ namespace ScreenCenter {
class Frame : public GPU::internal::LinkedElementCreator<Frame> {
private:
GPU::TILE top_left[2];
GPU::TILE top_right[2];
GPU::TILE bottom_left[2];
GPU::TILE bottom_right[2];
GPU::TILE top_left[2];
GPU::TILE top_right[2];
GPU::TILE bottom_left[2];
GPU::TILE bottom_right[2];
GPU::LINE_G_MULTI<5> border;
GPU::LINE_G_SINGLE cross[2];
public:
static constexpr Frame::Linked create() {
@ -30,6 +32,17 @@ namespace ScreenCenter {
frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
frame.border = Make::LINE_G(
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)},
GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, GPU::Display::Height - 1)},
GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(GPU::Display::Width - 1, GPU::Display::Height - 1)},
GPU::ColorVertex{GPU::Color24::Yellow(), Make::Vertex(GPU::Display::Width - 1, 0)},
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)}
);
frame.cross[0] = Make::LINE_G(frame.border[0], frame.border[2]);
frame.cross[1] = Make::LINE_G(frame.border[3], frame.border[1]);
return frame.linked();
}
};

View File

@ -69,6 +69,22 @@ namespace JabyEngine {
Vertex start_point;
Body points[N];
Termination end;
template<typename T = Body>
constexpr typename enable_if<is_same<T, Vertex>::value, Vertex>::type operator[](size_t idx) const {
if(idx == 0) {
return this->start_point;
}
return this->points[idx - 1];
}
template<typename T = Body>
constexpr typename enable_if<is_same<T, ColorVertex>::value, ColorVertex>::type operator[](size_t idx) const {
if(idx == 0) {
return ColorVertex::create(this->head.color, this->start_point);
}
return this->points[idx - 1];
}
};
}
@ -105,5 +121,13 @@ namespace JabyEngine {
return {.head = LineHead::create(start_point.color, IdentityCode, true), .start_point = start_point.position, .points = {rest...}, .end = Termination::create()};
}
};
using LINE_F_SINGLE = internal::SingleLine<Vertex>;
template<size_t N>
using LINE_F_MULTI = internal::MultiLine<Vertex, N - 1>;
using LINE_G_SINGLE = internal::SingleLine<ColorVertex>;
template<size_t N>
using LINE_G_MULTI = internal::MultiLine<ColorVertex, N - 1>;
}
}

View File

@ -187,21 +187,21 @@ namespace JabyEngine {
// ###################################################################
static constexpr GPU::internal::SingleLine<GPU::Vertex> LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const GPU::Vertex& end_point) {
static constexpr GPU::LINE_F_SINGLE LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const GPU::Vertex& end_point) {
return GPU::LINE_F::create(color, start_point, end_point);
}
template<typename...ARGS>
static constexpr GPU::internal::MultiLine<GPU::Vertex, sizeof...(ARGS)> LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const ARGS&...rest) {
static constexpr GPU::LINE_F_MULTI<sizeof...(ARGS) + 1> LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const ARGS&...rest) {
return GPU::LINE_F::create(color, start_point, rest...);
}
static constexpr GPU::internal::SingleLine<GPU::ColorVertex> LINE_G(const GPU::ColorVertex& start_point, const GPU::ColorVertex& end_point) {
static constexpr GPU::LINE_G_SINGLE LINE_G(const GPU::ColorVertex& start_point, const GPU::ColorVertex& end_point) {
return GPU::LINE_G::create(start_point, end_point);
}
template<typename...ARGS>
static constexpr GPU::internal::MultiLine<GPU::ColorVertex, sizeof...(ARGS)> LINE_G(const GPU::ColorVertex& start_point, const ARGS&...rest) {
static constexpr GPU::LINE_G_MULTI<sizeof...(ARGS) + 1> LINE_G(const GPU::ColorVertex& start_point, const ARGS&...rest) {
return GPU::LINE_G::create(start_point, rest...);
}