- if (fullWidth >= width - endWidth) { // completely filled
- srcRect.x = fullX + startWidth;
- srcRect.y = fullY;
- srcRect.w = repeatWidth;
- int fillWidth(width - startWidth - endWidth);
- int fillCursor(0);
- while (fillCursor < fillWidth) {
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
- destRect.x += repeatWidth;
- fillCursor += repeatWidth;
- }
- } else if (fullWidth <= startWidth) { // completely empty
- srcRect.x = emptyX + startWidth;
- srcRect.y = emptyY;
- srcRect.w = repeatWidth;
- int fillWidth(width - startWidth - endWidth);
- int fillCursor(0);
- while (fillCursor < fillWidth) {
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
- destRect.x += repeatWidth;
- fillCursor += repeatWidth;
- }
- } else { // partially filled/empty
- srcRect.x = fullX + startWidth;
- srcRect.y = fullY;
- srcRect.w = repeatWidth;
- int fillCursor(0);
- while (fillCursor < fullWidth) {
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
- destRect.x += repeatWidth;
- fillCursor += repeatWidth;
- }
- srcRect.x = emptyX + startWidth;
- srcRect.y = emptyY;
- int remaining(width - startWidth - endWidth);
- while (fillCursor < remaining) {
- SDL_BlitSurface(surface, &srcRect, dest, &destRect);
- destRect.x += repeatWidth;
- fillCursor += repeatWidth;
- }
+ srcRect.x = fullX + startWidth;
+ srcRect.y = fullY;
+ srcRect.w = repeatWidth;
+ while (filledWidth > repeatWidth) {
+ SDL_BlitSurface(surface, &srcRect, dest, &destRect);
+ destRect.x += repeatWidth;
+ filledWidth -= repeatWidth;
+ }
+ srcRect.x = emptyX + startWidth;
+ srcRect.y = emptyY;
+ while (emptyWidth > repeatWidth) {
+ SDL_BlitSurface(surface, &srcRect, dest, &destRect);
+ destRect.x += repeatWidth;
+ emptyWidth -= repeatWidth;