]> git.localhorst.tv Git - l2e.git/blob - src/sdl/utility.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / sdl / utility.cpp
1 #include "utility.h"
2
3 #include <cmath>
4
5 using geometry::Vector;
6
7 namespace sdl {
8
9 void HorizontalLine(SDL_Surface *dst, const Vector<int> &position, unsigned int length, Uint32 color) {
10         SDL_Rect destRect;
11         destRect.x = position.X();
12         destRect.y = position.Y();
13         destRect.w = length;
14         destRect.h = 1;
15         SDL_FillRect(dst, &destRect, color);
16 }
17
18 void VerticalLine(SDL_Surface *dst, const geometry::Vector<int> &position, unsigned int length, Uint32 color) {
19         SDL_Rect destRect;
20         destRect.x = position.X();
21         destRect.y = position.Y();
22         destRect.w = 1;
23         destRect.h = length;
24         SDL_FillRect(dst, &destRect, color);
25 }
26
27
28 void OutlineRect(SDL_Surface *dst, const Vector<int> &from, const Vector<int> &to, Uint32 color) {
29         SDL_Rect destRect;
30         destRect.x = std::min(from.X(), to.X());
31         destRect.y = std::min(from.Y(), to.Y());
32         destRect.w = std::abs(from.X() - to.X());
33         destRect.h = std::abs(from.Y() - to.Y());
34         OutlineRect(dst, &destRect, color);
35 }
36
37 void OutlineRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) {
38         SDL_Rect destRect;
39         destRect.x = dstrect->x;
40         destRect.y = dstrect->y;
41         destRect.w = dstrect->w;
42         destRect.h = 1;
43         SDL_FillRect(dst, &destRect, color);
44         destRect.y += dstrect->h - 1;
45         SDL_FillRect(dst, &destRect, color);
46         destRect.y = dstrect->y;
47         destRect.w = 1;
48         destRect.h = dstrect->h;
49         SDL_FillRect(dst, &destRect, color);
50         destRect.x += dstrect->w - 1;
51         SDL_FillRect(dst, &destRect, color);
52 }
53
54 }