4 * Created on: Aug 7, 2012
10 using geometry::Point;
14 // TODO: maybe create a cache for frames?
15 void Frame::Draw(SDL_Surface *dest, Point<int> position, int width, int height) const {
20 srcRect.w = borderWidth;
21 srcRect.h = borderHeight;
23 destRect.x = position.X();
24 destRect.y = position.Y();
25 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
28 srcRect.x += borderWidth;
29 srcRect.w = repeatWidth;
30 destRect.x += borderWidth;
31 int fullRepeatWidth(width - (2 * borderWidth));
33 while (repeatCursor < fullRepeatWidth) {
34 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
35 destRect.x += repeatWidth;
36 repeatCursor += repeatWidth;
40 srcRect.x += repeatWidth;
41 srcRect.w = borderWidth;
42 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
45 destRect.y += borderHeight;
46 int fullRepeatHeight(height - (2 * borderHeight));
48 while (hRepeatCursor < fullRepeatHeight) {
52 srcRect.y = yOffset + borderHeight;
53 srcRect.w = borderWidth;
54 srcRect.h = repeatHeight;
55 destRect.x = position.X();
56 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
60 srcRect.x += borderWidth;
61 srcRect.w = repeatWidth;
62 destRect.x += borderWidth;
63 while (repeatCursor < fullRepeatWidth) {
64 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
65 destRect.x += repeatWidth;
66 repeatCursor += repeatWidth;
70 srcRect.x += repeatWidth;
71 srcRect.w = borderWidth;
72 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
74 destRect.y += repeatHeight;
75 hRepeatCursor += repeatHeight;
80 srcRect.y = yOffset + borderHeight + repeatHeight;
81 srcRect.w = borderWidth;
82 srcRect.h = borderHeight;
83 destRect.x = position.X();
84 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
87 srcRect.x += borderWidth;
88 srcRect.w = repeatWidth;
89 destRect.x += borderWidth;
91 while (repeatCursor < fullRepeatWidth) {
92 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
93 destRect.x += repeatWidth;
94 repeatCursor += repeatWidth;
96 if (fullRepeatWidth < fullRepeatWidth) {
97 srcRect.w = fullRepeatWidth - fullRepeatWidth;
98 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
99 destRect.x += fullRepeatWidth - fullRepeatWidth;
102 // bottom-right corner
103 srcRect.x += repeatWidth;
104 srcRect.w = borderWidth;
105 SDL_BlitSurface(surface, &srcRect, dest, &destRect);