kRed = GUI_Slider(
   228.48, "Red", 0, 255 );
kGreen = GUI_Slider(
   193.29, "Green", 0, 255 );
kBlue = GUI_Slider(
   0.00, "Blue", 0, 255 );
kScaleMin = GUI_Slider(
   0.05, "Min Scale", 0, 5 );
kScaleMax = GUI_Slider(
   0.10, "Max Scale", 0, 5 );
kGravityMin = GUI_Slider(
	2.00, "Gravity Min", -200, 200 );
kGravityMax = GUI_Slider(
	20.00, "Gravity Max", -200, 200 );
kLifeMin = GUI_Slider(
   10000.00, "Life Min", 0, 20000 );
kLifeMax = GUI_Slider(
   19980.00, "Life Max", 0, 20000 );
kEmitSpeed = GUI_Slider(
	2.00, "Emit Speed", 0, 1000 );
kParticleMax = GUI_Slider(
   100.00, "Particle Max", 0, 10000 );
kWindMin = GUI_Slider(
	-10.00, "Wind Min", -200, 200 );
kWindMax = GUI_Slider(
	5.00, "Wind Max", -200, 200 );
kMaxAlpha = GUI_Slider(
   0.65, "Max Alpha", 0, 1 );
kBlending = GUI_Select(
    kBlendNormal,
   "Blend Mode",
   {
    { description = "Normal", value = kBlendNormal },
    { description = "Additive", value = kBlendAdditiveAlpha }
   } );

kRed = kRed / 255;
kGreen = kGreen / 255;
kBlue = kBlue / 255;

pVelocity = Allocate( 2 );
pAge = Allocate( 1 );
pLifeSpan = Allocate( 1 );
pRed = Allocate( 1 );
pGreen = Allocate( 1 );
pBlue = Allocate( 1 );
pColorAdjust = Allocate( 1 );

SetTexture( "particles/generic01" );
SetBlendMode( kBlending );
SetNumParticles( kParticleMax );

-- ------------------------------------------------------------

if not dLocus then
   dLocus = Vec2( 580, 40 ); 
end

if not dWidth then
   dWidth = 200;
end

if not dHeight then
   dHeight = 50;
end

pPosition:Init( Vec2( fRange( 0, dWidth ) - ( dWidth * 0.5 ) + dLocus[1],
                 fRange( 0, dHeight ) - ( dHeight * 0.5 ) + dLocus[2] ) );
pVelocity:Init( fRange( Vec2( kWindMin, kGravityMin ), Vec2( kWindMax, kGravityMax ) ) );
pAge:Init( 0 );
pScale:Init( fRange( kScaleMin, kScaleMax ) );
pLifeSpan:Init( fRange( kLifeMin, kLifeMax ) );
pColorAdjust:Init( fRange( 0.0, 1.0 ) );
pRed:Init( ( pColorAdjust * ( 1.0 - kRed ) ) + kRed );
pGreen:Init( ( pColorAdjust * ( 1.0 - kGreen ) ) + kGreen );
pBlue:Init( ( pColorAdjust * ( 1.0 - kBlue ) ) + kBlue );

-- ------------------------------------------------------------

pPosition:Anim( pPosition + fTimeScale( pVelocity ) );
pAge:Anim( pAge + fAge() );
pColor:Anim( fFade( pAge,
                  Color( pRed, pGreen, pBlue, 0 ), 250,
                  Color( pRed, pGreen, pBlue, kMaxAlpha ), 5000,
                  Color( pRed, pGreen, pBlue, kMaxAlpha ), pLifeSpan,
                  Color( pRed, pGreen, pBlue, 0 ) ) );

Anim( fExpire( fGreater( pAge, pLifeSpan ) ) );

-- ------------------------------------------------------------

function Update( seconds )
   CreateParticles( seconds * kEmitSpeed );
end
