#pragma once #include #include "frame.hpp" void draw_circle(Frame *frame, int cx, int cy, int radius, COLOR outline); inline void draw_circle(Frame *frame, Point c, int radius, COLOR outline) { draw_circle(frame, c.x, c.y, radius, outline); } void draw_line(Frame *frame, int x1, int y1, int x2, int y2, COLOR color); inline void draw_line(Frame *frame, Point p1, Point p2, COLOR color) { draw_line(frame, p1.x, p1.y, p2.x, p2.y, color); } template struct draw_polyline_ { template friend void draw_polyline(Frame *frame, COLOR color, point_t ...points); template friend struct draw_polyline_; private: }; template struct draw_polyline_ { template friend void draw_polyline(Frame *frame, COLOR color, point_t ...points); template friend struct draw_polyline_; private: static_assert(std::is_same_v); static_assert(std::is_same_v); static void draw(Frame *frame, COLOR color, p0_t p0, p1_t p1, pp_t ...points) { draw_line(frame, p0, p1, color); draw_polyline_::draw(frame, color, p1, points...); } static constexpr bool HAS_ANY = true; static Point first(p0_t p0, p1_t p1, pp_t ...points) { return p0; } static Point last(p0_t p0, p1_t p1, pp_t ...points) { return draw_polyline_::last(p1, points...); } }; template struct draw_polyline_ { template friend void draw_polyline(Frame *frame, COLOR color, point_t ...points); template friend struct draw_polyline_; private: static_assert(std::is_same_v); static void draw(Frame *frame, COLOR color, p0_t p0) {} static constexpr bool HAS_ANY = true; static Point first(p0_t p0) { return p0; } static Point last(p0_t p0) { return p0; } }; template<> struct draw_polyline_<> { template friend void draw_polyline(Frame *frame, COLOR color, point_t ...points); template friend struct draw_polyline_; private: static void draw(Frame *frame, COLOR color) {} static constexpr bool HAS_ANY = false; static Point first() { return Point{0, 0}; } static Point last() { return Point{0, 0}; } }; template void draw_polyline(Frame *frame, COLOR color, point_t ...points) { if constexpr (!draw_polyline_::HAS_ANY) {} else { draw_polyline_::draw(frame, color, points...); draw_line(frame, draw_polyline_::last(points...), draw_polyline_::first(points...), color); } }