SetParticleColor
This function determines a particle's starting or ending color.
Syntax
- void SetParticleColor(float r, float g, float b, const float & a, int mode)
Parameters
- r: - a float between 0.0 and 1.0 stating how red a particle should be.
- g: - a float between 0.0 and 1.0 stating how green a particle should be.
- b: - a float between 0.0 and 1.0 stating how blue a particle should be.
- a: - a float between 0.0 and 1.0 stating the alpha value, 0 being transparent and 1 being fully opaque.
- mode: - states whether the initial or final color is being set. 0 = starting color, 1 = final color.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->Move(0, 0, -3);
//Create an emitter
Emitter* emitter = Emitter::Create(50);
emitter->SetParticleColor(1, 0, 0, 1, 0); //inital color: red
emitter->SetParticleColor(0, 1, 0, 1, 1); //final color: green
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
context->SetBlendMode(Blend::Alpha);
context->DrawText("Initial Color: " + (emitter->GetParticleColor(0)).ToString(), 2, 2);
context->DrawText("Final Color: " + (emitter->GetParticleColor(1)).ToString(), 2, 22);
context->SetBlendMode(Blend::Solid);
context->Sync();
}
}