]> git.localhorst.tv Git - space.git/blobdiff - src/graphics/Canvas.cpp
fix grid2 low step optimization
[space.git] / src / graphics / Canvas.cpp
index 45997c6b3d3ad92cac6b5c38e6ff29ec570b3b71..768037efbc04bbcdc3269a7de930af4aaaf60135 100644 (file)
@@ -95,6 +95,25 @@ void Canvas::Cross(Vector<int> pos, int extent) {
                Vector<int>(pos.x, pos.y + extent));
 }
 
+void Canvas::Arrow(Vector<int> from, Vector<int> to) {
+       Line(from, to);
+       Vector<float> delta(to - from);
+       delta = delta / Length(delta);
+
+       Line(to, to + Vector<int>(Rotate90(delta) * 5.0f - (delta * 5.0f)));
+       Line(to, to + Vector<int>(Rotate270(delta) * 5.0f - (delta * 5.0f)));
+}
+
+void Canvas::Triangle(Vector<int> v1, Vector<int> v2, Vector<int> v3) {
+       SDL_Point points[4] = { v1, v2, v3, v1 };
+       SDL_RenderDrawLines(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_RenderDrawLines(canv, points, 5);
+}
+
 
 namespace {
 
@@ -164,7 +183,7 @@ void Grid2Impl(
                canv.SetColor(c1);
                canv.FillRect(pos, size);
                canv.SetColor(c2);
-               GridImpl(canv, pos, size, step);
+               GridImpl(canv, pos, size, step * Vector<Scalar>(n));
                return;
        }