Vector<int>(pos.x, pos.y + extent));
}
+void Canvas::Triangle(Vector<int> v1, Vector<int> v2, Vector<int> v3) {
+ SDL_Point points[4] = { v1, v2, v3, v1 };
+ SDL_RenderDrawPoints(canv, points, 4);
+}
+
+void Canvas::Quad(Vector<int> v1, Vector<int> v2, Vector<int> v3, Vector<int> v4) {
+ SDL_Point points[5] = { v1, v2, v3, v4, v1 };
+ SDL_RenderDrawPoints(canv, points, 5);
+}
+
namespace {
void Dot(Vector<int> pos);
void Cross(Vector<int> pos, int extent);
+ void Triangle(Vector<int>, Vector<int>, Vector<int>);
+ void Quad(Vector<int>, Vector<int>, Vector<int>, Vector<int>);
void Grid(Vector<int> pos, Vector<int> size, Vector<int> step);
void Grid(Vector<int> pos, Vector<int> size, Vector<float> step);
#include <algorithm>
#include <ostream>
+#include <SDL.h>
namespace space {
return *this;
}
+ SDL_Point ToPoint() const {
+ SDL_Point p;
+ p.x = x;
+ p.y = y;
+ return p;
+ }
+
public:
Scalar x;
Scalar y;
};
+/// specialization with same layout as SDL_Point
+template<>
+class Vector<int>
+: public SDL_Point {
+
+public:
+ constexpr Vector() : SDL_Point({0, 0}) { }
+ constexpr Vector(int x, int y) : SDL_Point({x, y}) { }
+
+ template<class Other>
+ constexpr Vector(Vector<Other> other)
+ : SDL_Point({int(other.x), int(other.y)}) { }
+
+public:
+ Vector<int> &operator +=(Vector<int> other) {
+ x += other.x;
+ y += other.y;
+ return *this;
+ }
+ Vector<int> &operator -=(Vector<int> other) {
+ x -= other.x;
+ y -= other.y;
+ return *this;
+ }
+
+ SDL_Point ToPoint() const {
+ return *this;
+ }
+
+};
+
template<class Scalar>
constexpr Vector<Scalar> operator -(Vector<Scalar> v) {