/*
* call-seq:
* fill(color,rect=nil)
*
* Fill all or part of a Surface with a color.
*
* This method takes these arguments:
* color:: color to fill with, in the form +[r,g,b]+ or +[r,g,b,a]+ (for
* partially transparent fills).
* rect:: a Rubygame::Rect representing the area of the surface to fill
* with color. Omit to fill the entire surface.
*/
VALUE rbgm_surface_fill( int argc, VALUE *argv, VALUE self )
{
SDL_Surface *surf;
SDL_Rect *rect;
Uint32 color;
Uint8 r,g,b,a;
VALUE vcolor, vrect;
Data_Get_Struct(self, SDL_Surface, surf);
rb_scan_args(argc, argv, "11", &vcolor, &vrect);
vcolor = convert_color(vcolor);
extract_rgba_u8_as_u8(vcolor, &r, &g, &b, &a);
color = SDL_MapRGBA(surf->format, r,g,b,a);
if( NIL_P(vrect) )
{
SDL_FillRect(surf,NULL,color);
}
else
{
vrect = convert_to_array(vrect);
rect = make_rect(\
NUM2INT(rb_ary_entry(vrect,0)),\
NUM2INT(rb_ary_entry(vrect,1)),\
NUM2INT(rb_ary_entry(vrect,2)),\
NUM2INT(rb_ary_entry(vrect,3))\
);
SDL_FillRect(surf,rect,color);
free(rect);
}
return self;
}