3 #include "../sdl/utility.h"
5 using geometry::Vector;
11 const Vector<int> &size,
12 const Vector<int> &offset)
24 void Texture::Render(SDL_Surface *dest, const Vector<int> &from, const Vector<int> &to) const {
26 destRect.x = from.X();
27 destRect.y = from.Y();
28 if (!surface || size == Vector<int>()) {
29 destRect.w = to.X() - from.X();
30 destRect.h = to.Y() - from.Y();
31 SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
36 srcRect.x = offset.X();
37 srcRect.y = offset.Y();
39 for (destRect.y = from.Y(); destRect.y < to.Y(); destRect.y += size.Y()) {
41 destRect.h = size.Y();
42 if (destRect.y + destRect.h > to.Y()) {
43 srcRect.h = to.Y() - destRect.y;
44 destRect.h = to.Y() - destRect.y;
46 for (destRect.x = from.X(); destRect.x < to.X(); destRect.x += size.X()) {
48 destRect.w = size.X();
49 if (destRect.x + destRect.w > to.X()) {
50 srcRect.w = to.X() - destRect.x;
51 destRect.w = to.X() - destRect.x;
53 SDL_BlitSurface(surface, &srcRect, dest, &destRect);