04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

258<br />

//particle limits<br />

int timeLimit = 1000;<br />

int particleCount = 100;<br />

int[]particleLimits = { timeLimit, particleCount };<br />

//particle dynamics<br />

float amplitudeMin = .5;<br />

float amplitudeMax = 4.0;<br />

float frequencyMin = 4.0;<br />

float frequencyMax = 40.0;<br />

float materialMin = .25; // lead<br />

float materialMax = .99; // rubber<br />

float[]particleDynamics = { amplitudeMin, amplitudeMax, ➥<br />

frequencyMin, frequencyMax, materialMin, materialMax};<br />

// speed limits<br />

float accelMin = .005;<br />

float accelMax = .2;<br />

float xSpeedMin = -2.0;<br />

float xSpeedMax = 2.0;<br />

float[]speedLimits = { xSpeedMin, xSpeedMax, ➥<br />

accelMin, accelMax };<br />

float gravity = .85;<br />

//position of particle emitter<br />

float emitterX = width/2;<br />

float emitterY = 0;<br />

float[]world = { gravity, emitterX, emitterY };<br />

//start particle engine<br />

setParticles(strokeStyle, particleLimits, ➥<br />

particleDynamics, speedLimits, world);<br />

}<br />

// main particle engine - fully parameterized<br />

void setParticles(float[]strokeStyle, int[]particleLimits,<br />

float[]particleDynamics, float[]speedLimits, float[]world){<br />

//create arrays<br />

float[]xSpeed = new float[particleLimits[1]];<br />

float[]ySpeed = new float[particleLimits[1]];<br />

float[]accel = new float[particleLimits[1]];<br />

float[]x = new float[particleLimits[1]];<br />

float[]y = new float[particleLimits[1]];<br />

float[]amplitude = new float[particleLimits[1]];<br />

float[]frequency = new float[particleLimits[1]];<br />

float[]material = new float[particleLimits[1]];

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!