added blitRect to api

This commit is contained in:
Shaun Inman 2023-01-16 21:34:00 -05:00
parent 32dc04c780
commit baf2c0da7f
2 changed files with 20 additions and 0 deletions

View file

@ -355,6 +355,25 @@ void GFX_blitPill(int asset, SDL_Surface* dst, SDL_Rect* dst_rect) {
} }
GFX_blitAsset(asset, &(SDL_Rect){r,0,r,h}, dst, &(SDL_Rect){x,y}); GFX_blitAsset(asset, &(SDL_Rect){r,0,r,h}, dst, &(SDL_Rect){x,y});
} }
void GFX_blitRect(int asset, SDL_Surface* dst, SDL_Rect* dst_rect) {
int x = dst_rect->x;
int y = dst_rect->y;
int w = dst_rect->w;
int h = dst_rect->h;
int c = asset_rgbs[asset];
SDL_Rect* rect = &asset_rects[asset];
int d = rect->w;
int r = d / 2;
GFX_blitAsset(asset, &(SDL_Rect){0,0,r,r}, dst, &(SDL_Rect){x,y});
SDL_FillRect(dst, &(SDL_Rect){x+r,y,w-d,r}, c);
GFX_blitAsset(asset, &(SDL_Rect){r,0,r,r}, dst, &(SDL_Rect){x+w-r,y});
SDL_FillRect(dst, &(SDL_Rect){x,y+r,w,h-d}, c);
GFX_blitAsset(asset, &(SDL_Rect){0,r,r,r}, dst, &(SDL_Rect){x,y+h-r});
SDL_FillRect(dst, &(SDL_Rect){x+r,y+h-r,w-d,r}, c);
GFX_blitAsset(asset, &(SDL_Rect){r,r,r,r}, dst, &(SDL_Rect){x+w-r,y+h-r});
}
void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect) { void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect) {
SDL_Rect rect = asset_rects[ASSET_BATTERY]; SDL_Rect rect = asset_rects[ASSET_BATTERY];
int x = dst_rect->x; int x = dst_rect->x;

View file

@ -78,6 +78,7 @@ int GFX_truncateDisplayName(const char* in_name, char* out_name, int max_width);
// NOTE: all dimensions should be pre-scaled // NOTE: all dimensions should be pre-scaled
void GFX_blitAsset(int asset, SDL_Rect* src_rect, SDL_Surface* dst, SDL_Rect* dst_rect); void GFX_blitAsset(int asset, SDL_Rect* src_rect, SDL_Surface* dst, SDL_Rect* dst_rect);
void GFX_blitPill(int asset, SDL_Surface* dst, SDL_Rect* dst_rect); void GFX_blitPill(int asset, SDL_Surface* dst, SDL_Rect* dst_rect);
void GFX_blitRect(int asset, SDL_Surface* dst, SDL_Rect* dst_rect);
void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect); void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect);
int GFX_getButtonWidth(char* hint, char* button); int GFX_getButtonWidth(char* hint, char* button);
void GFX_blitButton(char* hint, char*button, SDL_Surface* dst, SDL_Rect* dst_rect); void GFX_blitButton(char* hint, char*button, SDL_Surface* dst, SDL_Rect* dst_rect);