Effects 2D.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /******************************************************************************
  2. Use these functions to achieve post processing effects.
  3. /******************************************************************************/
  4. struct RippleFx // Ripple Effect
  5. {
  6. Flt xx, xy , // matrix transformation parameters, default=(60, 40)
  7. yx, yy , // matrix transformation parameters, default=(60, 35)
  8. step , // effect time , default=Time.appTime()
  9. power , // ripple power , default=0.005
  10. alpha_scale, // alpha scale , default=0
  11. alpha_add ; // alpha add , default=1
  12. Vec2 center ; // image center position in UV coordinates (0..1, 0..1), default=(0.5, 0.5)
  13. // final_ripple_pixel_alpha = DistanceFrom(center)*alpha_scale + alpha_add
  14. RippleFx& reset(); // reset to default values
  15. void draw (C Image &image, C Rect &rect); // draw 'image' using ripple effect, 'rect'=screen rectangle
  16. RippleFx() {reset();}
  17. };
  18. /******************************************************************************/
  19. struct TitlesFx // Titles Swirl Effect
  20. {
  21. Flt step , // time (0..Inf, default=Time.appTime()*2)
  22. center, // center y (in UV coordinates 0..1, default=0.5 )
  23. range , // range of sharp visibility (default=0.4 )
  24. smooth, // range of smoothed visibility (default=0.1 )
  25. swirl ; // swirl amount (default=0.015)
  26. TitlesFx& reset(); // reset to default values
  27. void draw (C Image &image); // draw 'image' using titles swirl effect
  28. TitlesFx() {reset();}
  29. };
  30. /******************************************************************************/
  31. STRUCT(ColorMatrix , Matrix) // Color Transformation Matrix
  32. //{
  33. ColorMatrix& setRGB ( ); // set RGB transformation
  34. ColorMatrix& setRBG ( ); // set RBG transformation
  35. ColorMatrix& setGRB ( ); // set GRB transformation
  36. ColorMatrix& setGBR ( ); // set GBR transformation
  37. ColorMatrix& setBRG ( ); // set BRG transformation
  38. ColorMatrix& setBGR ( ); // set BGR transformation
  39. ColorMatrix& setMono( ); // set monochrome transformation
  40. ColorMatrix& setHue (Flt hue); // set approximate hue transformation, 'hue'=hue adjustment (0..1)
  41. void draw(Flt alpha=1); // apply full-screen color transformation, 'alpha'=effect opacity (0..1)
  42. };
  43. void ColorTransHB (Flt hue, Flt brightness, Flt alpha=1); // apply full-screen correct Hue- Brightness color transformation, 'hue'=hue adjustment (0..1), , 'brightness'=brightness adjustment (0..Inf)
  44. void ColorTransHSB(Flt hue, Flt saturation, Flt brightness, Flt alpha=1); // apply full-screen correct Hue-Saturation-Brightness color transformation, 'hue'=hue adjustment (0..1), 'saturation'=saturation adjustment (0..Inf), 'brightness'=brightness adjustment (0..Inf), 'alpha'=effect opacity (0..1)
  45. /******************************************************************************/
  46. void FadeFx (C Image &image, Flt time , Image *fade_modified=null ); // draw 'image' with Fade Effect, 'time' =effect time (0..1 ), 'fade_modifier'=optional fade modifier texture (only its alpha channel is used)
  47. void WaveFx ( Flt time , Flt scale ); // apply full-screen Wave Effect, 'time' =effect time (0..Inf), 'scale'=wave scale (0..1)
  48. void RadialBlurFx( Flt scale, Flt alpha=1, C Vec2 &center=Vec2(0,0)); // apply full-screen Radial Blur Effect, 'scale'=blur scale (0..Inf), 'alpha'=effect opacity (0..1), 'center'=screen point center of fading
  49. /******************************************************************************/