]> git.localhorst.tv Git - space.git/blobdiff - src/graphics/Canvas.cpp
fix grid2 low step optimization
[space.git] / src / graphics / Canvas.cpp
index e4befc0bf04886003dc3d8f04ce409c0d5f15c46..768037efbc04bbcdc3269a7de930af4aaaf60135 100644 (file)
@@ -95,14 +95,23 @@ 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_RenderDrawPoints(canv, points, 4);
+       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_RenderDrawPoints(canv, points, 5);
+       SDL_RenderDrawLines(canv, points, 5);
 }
 
 
@@ -174,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;
        }