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