]> git.localhorst.tv Git - space.git/blobdiff - src/graphics/primitive.cpp
move to SDL2
[space.git] / src / graphics / primitive.cpp
diff --git a/src/graphics/primitive.cpp b/src/graphics/primitive.cpp
deleted file mode 100644 (file)
index f8b5863..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-#include "primitive.h"
-
-#include <algorithm>
-
-using namespace std;
-
-
-namespace space {
-
-void Fill(SDL_Surface *dst, Color c) {
-       Fill(dst, c.MapRGBA(dst));
-}
-
-void Fill(SDL_Surface *dst, Uint32 color) {
-       SDL_FillRect(dst, nullptr, color);
-}
-
-
-void HLine(SDL_Surface *dst, Vector<int> pos, int len, Color c) {
-       HLine(dst, pos, len, c.MapRGBA(dst));
-}
-
-void HLine(SDL_Surface *dst, Vector<int> pos, int len, Uint32 c) {
-       FillRect(dst, pos, Vector<int>(len, 1), c);
-}
-
-void VLine(SDL_Surface *dst, Vector<int> pos, int len, Color c) {
-       VLine(dst, pos, len, c.MapRGBA(dst));
-}
-
-void VLine(SDL_Surface *dst, Vector<int> pos, int len, Uint32 c) {
-       FillRect(dst, pos, Vector<int>(1, len), c);
-}
-
-
-void FillRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Color c) {
-       FillRect(dst, pos, size, c.MapRGBA(dst));
-}
-
-void FillRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Uint32 c) {
-       SDL_Rect destRect;
-       destRect.x = pos.x;
-       destRect.y = pos.y;
-       destRect.w = size.x;
-       destRect.h = size.y;
-       SDL_FillRect(dst, &destRect, c);
-}
-
-void OutlineRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Color c) {
-       OutlineRect(dst, pos, size, c.MapRGBA(dst));
-}
-
-void OutlineRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Uint32 c) {
-       SDL_Rect destRect;
-
-       destRect.x = pos.x;
-       destRect.y = pos.y;
-       destRect.w = size.x;
-       destRect.h = 1;
-       SDL_FillRect(dst, &destRect, c);
-
-       destRect.x = pos.x;
-       destRect.y = pos.y + size.y - 1;
-       destRect.w = size.x;
-       destRect.h = 1;
-       SDL_FillRect(dst, &destRect, c);
-
-       destRect.x = pos.x;
-       destRect.y = pos.y;
-       destRect.w = 1;
-       destRect.h = size.y;
-       SDL_FillRect(dst, &destRect, c);
-
-       destRect.x = pos.x + size.x - 1;
-       destRect.y = pos.y;
-       destRect.w = 1;
-       destRect.h = size.y;
-       SDL_FillRect(dst, &destRect, c);
-}
-
-
-void Cross(
-               SDL_Surface *dst,
-               Vector<int> pos,
-               int extent,
-               Color color) {
-       Uint32 c = color.MapRGBA(dst);
-       int len = 2 * extent + 1;
-
-       HLine(dst, Vector<int>(pos.x - extent, pos.y), len, c);
-       VLine(dst, Vector<int>(pos.x, pos.y - extent), len, c);
-}
-
-
-void Grid(
-               SDL_Surface *dst,
-               Vector<int> first,
-               Vector<int> second,
-               Vector<int> size,
-               Color color) {
-       Uint32 c = color.MapRGBA(dst);
-
-       Vector<int> from = min(first, second);
-       Vector<int> to = max(first, second);
-
-       if (size.x <= 1 || size.y <= 1) {
-               FillRect(dst, from, to - from, c);
-               return;
-       }
-
-       if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
-               return;
-       }
-
-       while (from.x < -size.x) from.x += size.x;
-       while (from.y < -size.y) from.y += size.y;
-       while (to.x > dst->w + size.x) to.x -= size.x;
-       while (to.y > dst->h + size.y) to.y -= size.y;
-
-       int width = to.x - from.x;
-       int height = to.y - from.y;
-
-       for (Vector<int> pos(from); pos.x <= to.x; pos.x += size.x) {
-               VLine(dst, pos, height, c);
-       }
-       for (Vector<int> pos(from); pos.y <= to.y; pos.y += size.y) {
-               HLine(dst, pos, width, c);
-       }
-}
-
-void Grid(
-               SDL_Surface *dst,
-               Vector<int> first,
-               Vector<int> second,
-               Vector<float> size,
-               Color color) {
-       Uint32 c = color.MapRGBA(dst);
-
-       Vector<int> from = min(first, second);
-       Vector<int> to = max(first, second);
-
-       if (size.x <= 1 || size.y <= 1) {
-               FillRect(dst, from, to - from, c);
-               return;
-       }
-
-       if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
-               return;
-       }
-
-       while (from.x < -size.x) from.x += size.x;
-       while (from.y < -size.y) from.y += size.y;
-       while (to.x > dst->w + size.x) to.x -= size.x;
-       while (to.y > dst->h + size.y) to.y -= size.y;
-
-       float width = to.x - from.x;
-       float height = to.y - from.y;
-
-       for (Vector<float> pos(from); pos.x <= to.x; pos.x += size.x) {
-               VLine(dst, pos, height, c);
-       }
-       for (Vector<float> pos(from); pos.y <= to.y; pos.y += size.y) {
-               HLine(dst, pos, width, c);
-       }
-}
-
-void Grid2(
-               SDL_Surface *dst,
-               Vector<int> first,
-               Vector<int> second,
-               Vector<int> size,
-               Vector<int> n,
-               Color color1,
-               Color color2) {
-       Uint32 c1 = color1.MapRGBA(dst);
-       Uint32 c2 = color2.MapRGBA(dst);
-
-       Vector<int> from = min(first, second);
-       Vector<int> to = max(first, second);
-
-       if (size.x <= 1 || size.y <= 1) {
-               FillRect(dst, from, to - from, c1);
-               Grid(dst, from, to, size * n, color2);
-               return;
-       }
-
-       if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
-               return;
-       }
-
-       Vector<int> i(0, 0);
-       while (from.x < -size.x) { from.x += size.x; ++i.x; }
-       while (from.y < -size.y) { from.y += size.y; ++i.y; }
-       while (to.x > dst->w + size.x) to.x -= size.x;
-       while (to.y > dst->h + size.y) to.y -= size.y;
-
-       int width = to.x - from.x;
-       int height = to.y - from.y;
-
-       for (Vector<int> pos(from); pos.x <= to.x; pos.x += size.x) {
-               VLine(dst, pos, height, (i.x++ % n.x) ? c1 : c2);
-       }
-       for (Vector<int> pos(from); pos.y <= to.y; pos.y += size.y) {
-               HLine(dst, pos, width, (i.y++ % n.y) ? c1 : c2);
-       }
-}
-
-void Grid2(
-               SDL_Surface *dst,
-               Vector<int> first,
-               Vector<int> second,
-               Vector<float> size,
-               Vector<int> n,
-               Color color1,
-               Color color2) {
-       Uint32 c1 = color1.MapRGBA(dst);
-       Uint32 c2 = color2.MapRGBA(dst);
-
-       Vector<int> from = min(first, second);
-       Vector<int> to = max(first, second);
-
-       if (size.x <= 1 || size.y <= 1) {
-               FillRect(dst, from, to - from, c1);
-               Grid(dst, from, to, size * Vector<float>(n), color2);
-               return;
-       }
-
-       if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
-               return;
-       }
-
-       Vector<int> i(0, 0);
-       while (from.x < -size.x) { from.x += size.x; ++i.x; }
-       while (from.y < -size.y) { from.y += size.y; ++i.y; }
-       while (to.x > dst->w + size.x) to.x -= size.x;
-       while (to.y > dst->h + size.y) to.y -= size.y;
-
-       float width = to.x - from.x;
-       float height = to.y - from.y;
-
-       for (Vector<float> pos(from); pos.x <= to.x; pos.x += size.x) {
-               VLine(dst, pos, height, (i.x++ % n.x) ? c1 : c2);
-       }
-       for (Vector<float> pos(from); pos.y <= to.y; pos.y += size.y) {
-               HLine(dst, pos, width, (i.y++ % n.y) ? c1 : c2);
-       }
-}
-
-}