-- ================================================================================
gTexture = GUI_PickTexture("sparkle","Particle Texture");
gBlendMode = GUI_Select(
   kBlendAdditiveAlpha,
   "Blend Mode",
   {
      { description="Normal", value=kBlendNormal},
      { description="Additive Alpha", value=kBlendAdditiveAlpha},
      { description="Multiplicative", value=kBlendMultiplicative},
      { description="Subtractive", value=kBlendSubtractive},
      { description="Opaque", value=kBlendOpaque},
   }
);
gNumParticles = GUI_Slider(
	6.00,
   "Max Number of Particles",
   0,1000);
gPPS = GUI_Slider(
	6.00,
   "Particles Per Second",
   0,200);
gParticleLife = GUI_Slider(
	1041.00,
   "Particle Life",
   0,3000);
gInitColor = GUI_ColorPick(
255,255,255,193,
   "Initial Color");
gInitPosX = GUI_Slider(
   25.00,
   "Initial X Offset",
   0,100);
gInitPosY = GUI_Slider(
   27.30,
   "Initial Y Offset",
   0,100);
gInitVelX = GUI_Slider(
   0.34,
   "Initial X Velocity",
   -10,10);
gInitVelY = GUI_Slider(
   0.34,
   "Initial Y Velocity",
   -10,10);
gInitWeight = GUI_Slider(
   0,
   "Initial Weight",
   -10,10);
gInitRot = GUI_Slider(
   0.38,
   "Initial Rotation",
   0,6.28);
gInitSize = GUI_Slider(
   0.04,
   "Initial Size",
   0.01,100);
gInitSizeRange = GUI_Slider(
   0.20,
   "Init Size Variation",
   0,100);
gVelocityOverTime = GUI_Graph(
   {
      Vec2(0.00,0.00),1000,
      Vec2(0.00,0.00)
   },
   Vec2(-5.00,-5.00),
   Vec2(5.00,5.00),
   {
      {0.00,0.00,time=0.00},
      {0.00,0.00,time=1000.00}
   },
   "Velocity Over Time");
gScaleOverTime = GUI_Graph(
   {
      0.06,501,
      1.28,499,
      0.00
   },
   0.00,
   10.00,
   {
      {0.06,time=0.00},
      {1.28,time=501.26},
      {0.00,time=1000.00}
   },
   "Scale Over Time");
gColorOverTime = GUI_Graph(
   {
      Color(0.69,0.84,0.12,0.01),262,
      Color(0.97,0.98,0.98,0.47),293,
      Color(0.66,0.73,0.24,0.39),266,
      Color(0.73,0.84,0.86,0.29),230,
      Color(0.85,0.82,0.82,0.0)
   },
   Color(0,0,0,0),
   Color(1,1,1,1),
   {
      {0.69,0.84,0.12,0.01,time=0.00},
      {0.97,0.98,0.98,0.47,time=262.57},
      {0.66,0.73,0.24,0.39,time=556.09},
      {0.73,0.84,0.86,0.29,time=822.91},
      {0.85,0.82,0.82,0.00,time=1053.15},
   },
   "Color Over Time");
-- ================================================================================
pAge = Allocate(1); 
pVelocity = Allocate(2);
pRotation = Allocate(1);
-- ================================================================================
SetTexture(gTexture);
SetBlendMode(gBlendMode);
SetNumParticles(gNumParticles);
if not dLocus then
   dLocus= Vec2(0,0) ; 
end
pPosition:Init( dLocus+fRange(Vec2(-gInitPosX,-gInitPosY),Vec2(gInitPosX,gInitPosY)) );
pScale:Init( fRange(gInitSize,gInitSize+gInitSizeRange) );
pColor:Init(gInitColor);
pAge:Init(0);
pVelocity:Init(fRange(Vec2(-gInitVelX,-gInitVelY),Vec2(gInitVelX,gInitVelY)));
pRotation:Init(gInitRot);
pUp:Init(f2dRotation(pRotation));
-- ================================================================================
pAge:Anim( pAge+fAge() );
pVelocity:Anim(Vec2(0,gInitWeight)+pVelocity+fFade(pAge,toparams(gVelocityOverTime)));
pPosition:Anim(pPosition+pVelocity);
pColor:Anim(fFade(pAge,toparams(gColorOverTime)));
--pScale:Anim(pScale+fFade(pAge,toparams(gScaleOverTime)));
Anim( fExpire( fGreater(pAge,gParticleLife) ) );
-- ================================================================================
function Update(seconds)
   CreateParticles( seconds * gPPS );
end
