#include <cmath>
#include "spawner.h"
#include "random.h"

namespace render{
namespace fx{

vec2f particlesSpawnerRect::getSpawnPos(float time) noexcept
{
    return size.math(time)*random2();
}

vec2f particlesSpawnerRound::getSpawnPos(float time) noexcept
{
    vec2f dir;
    sincosf(3.1415f*random(), &dir.x, &dir.y);
    return size.math(time)*dir*urandom();
}

vec2f particlesSpawnerRing::getSpawnPos(float time) noexcept
{
    vec2f dir;
    sincosf(3.1415f*random(), &dir.x, &dir.y);
    vec4f s = size.math(time);
    return vec2f(s.x, s.y)*dir*urandom()+vec2f(s.z, s.w)*dir;
}

particlesSpawner *particleRectSpawnerInfo::create()
{
    particlesSpawnerRect *spawner = new particlesSpawnerRect;
    sizeParam.math(&spawner->size);
    return spawner;
}

}}
