]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Frame.h
023b694785678123d6f93d10cc7e26523e2a778f
[l2e.git] / src / graphics / Frame.h
1 #ifndef GRAPHICS_FRAME_H_
2 #define GRAPHICS_FRAME_H_
3
4 #include "../math/Vector.h"
5
6 #include <SDL.h>
7
8 namespace graphics {
9
10 class Frame {
11
12 public:
13         static const int TYPE_ID = 405;
14
15 public:
16         explicit Frame(SDL_Surface *s = 0, int borderWidth = 1, int borderHeight = 1, int repeatWidth = 1, int repeatHeight = 1, int xOffset = 0, int yOffset = 0)
17         : surface(s), borderSize(borderWidth, borderHeight), repeatSize(repeatWidth, repeatHeight), offset(xOffset, yOffset) { }
18
19 public:
20         int MinWidth() const { return 2 * BorderWidth(); }
21         int MinHeight() const { return 2 * BorderHeight(); }
22         int BorderWidth() const { return BorderSize().X(); }
23         int BorderHeight() const { return BorderSize().Y(); }
24         const math::Vector<int> BorderSize() const { return borderSize; }
25         int RepeatWidth() const { return RepeatSize().X(); }
26         int RepeatHeight() const { return RepeatSize().Y(); }
27         const math::Vector<int> RepeatSize() const { return repeatSize; }
28         void Draw(SDL_Surface *dest, const math::Vector<int> &position, int width, int height) const;
29
30 public:
31         void SetSurface(SDL_Surface *s) { surface = s; }
32         void SetBorderSize(const math::Vector<int> &s) { borderSize = s; }
33         void SetRepeatSize(const math::Vector<int> &s) { repeatSize = s; }
34         void SetOffset(const math::Vector<int> &o) { offset = o; }
35
36         static void CreateTypeDescription();
37         static void Construct(void *);
38
39 private:
40         SDL_Surface *surface;
41         math::Vector<int> borderSize;
42         math::Vector<int> repeatSize;
43         math::Vector<int> offset;
44
45 };
46
47 }
48
49 #endif /* GRAPHICS_FRAME_H_ */