/* * call-seq: * set_colorkey(color,flags=0) * * Set the colorkey of the surface. See Surface#colorkey for a description * of colorkeys. * * This method takes these arguments: * color:: color to use as the key, in the form [r,g,b]. Can be +nil+ to * un-set the colorkey. * flags:: 0 or Rubygame::SRC_COLORKEY (default) or * Rubygame::SRC_COLORKEY|Rubygame::SDL_RLEACCEL. Most people will * want the default, in which case this argument can be omitted. For * advanced users: this flag affects the surface as described in the * docs for the SDL C function, SDL_SetColorkey. */ VALUE rbgm_surface_set_colorkey( int argc, VALUE *argv, VALUE self) { SDL_Surface *surf; Uint32 color; Uint32 flags; Uint8 r,g,b; VALUE vcolor, vflags; Data_Get_Struct(self, SDL_Surface, surf); rb_scan_args(argc, argv, "11", &vcolor, &vflags); if( !NIL_P(vflags) ) { flags = NUM2UINT(vflags); } else { flags = SDL_SRCCOLORKEY; } if( RTEST(vcolor) ) { vcolor = convert_to_array(vcolor); r = NUM2UINT(rb_ary_entry(vcolor,0)); g = NUM2UINT(rb_ary_entry(vcolor,1)); b = NUM2UINT(rb_ary_entry(vcolor,2)); color = SDL_MapRGB(surf->format, r,g,b); } else { flags = 0; color = 0; } if(SDL_SetColorKey(surf,flags,color)!=0) rb_raise(eSDLError,"could not set colorkey: %s",SDL_GetError()); return self; }