-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFramedRect.cpp
More file actions
66 lines (52 loc) · 1.15 KB
/
Copy pathFramedRect.cpp
File metadata and controls
66 lines (52 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "FramedRect.h"
FramedRect::FramedRect(void)
{
this->x = 0;
this->y = 0;
this->w = 0;
this->h = 0;
this->border = 0;
}
FramedRect::FramedRect(int x, int y, int w, int h, int border)
{
this->x = x;
this->y = y;
this->w = w;
this->h = h;
this->border = border;
}
Uint32 FramedRect::convertColor(char r, char b, char g)
{
return SDL_MapRGB(DrawableSDL::surface->format, r, g, b);
}
void FramedRect::setBackground(char r, char g, char b)
{
this->backgroundColor = convertColor(r,g,b);
}
void FramedRect::setBorderColor(char r, char g, char b)
{
this->borderColor = convertColor(r,g,b);
}
void FramedRect::setBorderSize(int size)
{
this->border = size;
}
void FramedRect::draw(int x, int y)
{
DrawableSDL::draw(x,y);
SDL_Rect border;
SDL_Rect fronter;
fronter.x = this->x + x;
fronter.y = this->y + y;
fronter.w = w;
fronter.h = h;
border.x = x - this->border + this->x;
border.y = y - this->border + this->y;
border.w = w + 2*this->border;
border.h = h + 2*this->border;
SDL_FillRect(DrawableSDL::surface, &border, borderColor);
SDL_FillRect(DrawableSDL::surface, &fronter, backgroundColor);
}
FramedRect::~FramedRect(void)
{
}