- 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;
- }
- }
-
- // end
- // full part
- if (fullWidth >= width) { // completely filled
- srcRect.x = fullX + startWidth + repeatWidth;
- srcRect.y = fullY;
- srcRect.w = endWidth;