4 * Created on: Aug 7, 2012
10 using geometry::Point;
14 void Gauge::Draw(SDL_Surface *dest, Point<int> position, int width, Uint8 fill) const {
15 SDL_Rect srcRect, destRect;
17 int filledWidth = fill * (width - startWidth - endWidth) / 255;
18 int emptyWidth = (255 - fill) * (width - startWidth - endWidth) / 255;
21 srcRect.w = startWidth;
23 destRect.x = position.X();
24 destRect.y = position.Y();
29 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
33 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
36 destRect.x = position.X() + startWidth;
39 srcRect.x = fullX + startWidth;
41 srcRect.w = repeatWidth;
42 while (filledWidth > repeatWidth) {
43 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
44 destRect.x += repeatWidth;
45 filledWidth -= repeatWidth;
47 srcRect.x = emptyX + startWidth;
49 while (emptyWidth > repeatWidth) {
50 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
51 destRect.x += repeatWidth;
52 emptyWidth -= repeatWidth;
58 srcRect.x = fullX + startWidth + repeatWidth;
60 SDL_BlitSurface(surface, &srcRect, dest, &destRect);
62 srcRect.x = emptyX + startWidth + repeatWidth;
64 SDL_BlitSurface(surface, &srcRect, dest, &destRect);