gmlscripts

draw_sprite_hdr

Sep 23rd, 2016
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// draw_sprite_hdr(sprite,subimg,x,y,r,g,b)
  2. {
  3.     var sprite, subimg, xposit, yposit, hdrRed, hdrGrn, hdrBlu;
  4.     sprite = argument0;
  5.     subimg = argument1;
  6.     xposit = argument2;
  7.     yposit = argument3;
  8.     hdrRed = argument4;
  9.     hdrGrn = argument5;
  10.     hdrBlu = argument6;
  11.    
  12.     // normal draw mode for the first pass
  13.     draw_set_blend_mode(bm_normal);
  14.    
  15.     do {
  16.         // determine color blending for this pass and then draw the sprite using it
  17.         color = make_color_rgb(min(max(0,hdrRed),255), min(max(0,hdrGrn),255), min(max(0,hdrBlu),255));
  18.         draw_sprite_ext(sprite, subimg, xposit, yposit, 1, 1, 0, color, 1);
  19.        
  20.         // remove a full pass of light
  21.         hdrRed -= 255;
  22.         hdrGrn -= 255;
  23.         hdrBlu -= 255;
  24.        
  25.         // every subsequent pass is drawn with additive blending
  26.         draw_set_blend_mode(bm_add);  
  27.        
  28.     // keep drawing until there is no more light
  29.     } until (max(hdrRed, hdrGrn, hdrBlu) <= 0);
  30.    
  31.     // restore blend mode to normal
  32.     draw_set_blend_mode(bm_normal);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment