- // middle
- destRect.y += BorderHeight();
- int fullRepeatHeight(height - (2 * BorderHeight()));
- int hRepeatCursor(0);
- while (hRepeatCursor < fullRepeatHeight) {
-
- // left border
- srcRect.x = offset.X();
- srcRect.y = offset.Y() + BorderHeight();
- srcRect.w = BorderWidth();
- srcRect.h = RepeatHeight();
- destRect.x = position.X();
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
-
- // fill
- repeatCursor = 0;
- srcRect.x += BorderWidth();
- srcRect.w = RepeatWidth();
- destRect.x += BorderWidth();
- while (repeatCursor < fullRepeatWidth) {
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
- destRect.x += RepeatWidth();
- repeatCursor += RepeatWidth();
- }
-
- // right border
- srcRect.x += RepeatWidth();
- srcRect.w = BorderWidth();
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
-
- destRect.y += RepeatHeight();
- hRepeatCursor += RepeatHeight();
- }
+ // left border
+ Texture(surface, Vector<int>(BorderWidth(), RepeatHeight()), Vector<int>(offset.X(), offset.Y() + BorderHeight()))
+ .Draw(dest, Vector<int>(position.X(), position.Y() + BorderHeight()), Vector<int>(position.X() + BorderWidth(), position.Y() + height - BorderHeight()));
+
+ // center fill
+ Texture(surface, RepeatSize(), Vector<int>(offset.X() + BorderWidth(), offset.Y() + BorderHeight()))
+ .Draw(dest, position + BorderSize(), position + Vector<int>(width, height) - BorderSize());
+
+ // right border
+ Texture(surface, Vector<int>(BorderWidth(), RepeatHeight()), Vector<int>(offset.X() + BorderWidth() + RepeatWidth(), offset.Y() + BorderHeight()))
+ .Draw(dest, Vector<int>(position.X() + width - BorderWidth(), position.Y() + BorderHeight()), Vector<int>(position.X() + width, position.Y() + height - BorderHeight()));