]> git.localhorst.tv Git - orbi.git/blobdiff - src/graphics/Canvas.cpp
rotatable arm for character entities
[orbi.git] / src / graphics / Canvas.cpp
index 3f1c3d117ef1473446d91dc5096b146698d34b93..9a163e968d4b7321abc9c1520abd5731697e81b2 100644 (file)
@@ -81,22 +81,26 @@ void Canvas::Line(Vector<int> from, Vector<int> to) {
        SDL_RenderDrawLine(canv, from.x, from.y, to.x, to.y);
 }
 
-void Canvas::FillRect(Vector<int> pos, Vector<int> size) {
-       SDL_Rect destRect;
-       destRect.x = pos.x;
-       destRect.y = pos.y;
-       destRect.w = size.x;
-       destRect.h = size.y;
-       SDL_RenderFillRect(canv, &destRect);
+void Canvas::FillRect(Rect<int> rect) {
+       SDL_RenderFillRect(canv, &rect);
 }
 
-void Canvas::OutlineRect(Vector<int> pos, Vector<int> size) {
-       SDL_Rect destRect;
-       destRect.x = pos.x;
-       destRect.y = pos.y;
-       destRect.w = size.x;
-       destRect.h = size.y;
-       SDL_RenderDrawRect(canv, &destRect);
+void Canvas::OutlineRect(Rect<int> rect) {
+       SDL_RenderDrawRect(canv, &rect);
+}
+
+void Canvas::OutlineRectRot(Rect<float> rect, Vector<float> origin, float rot) {
+       const Vector<float> topLeft(rect.x, rect.y);
+       const Vector<float> topRight(rect.x + rect.w - 1, rect.y);
+       const Vector<float> botLeft(rect.x, rect.y + rect.h - 1);
+       const Vector<float> botRight(rect.x + rect.w - 1, rect.y + rect.h - 1);
+
+       Quad(
+               Rotate(topLeft - origin, rot) + origin,
+               Rotate(topRight - origin, rot) + origin,
+               Rotate(botRight - origin, rot) + origin,
+               Rotate(botLeft - origin, rot) + origin
+       );
 }