/** * CrazyWeaver * Interpolation test doodle * (see FlyingBall.interpol()) * * Joerg Reuter, jore[at]stachelig[dot]de * Creative Commons Attribution 3.0 license * http://stachelig.de * Heads up: http://sol.gfxile.net/interpolation */ int MAX_X = 640; int MAX_Y = 360; int NUM_BALLS = 10; int DURATION = 40; FlyingBall[] balls = new FlyingBall[NUM_BALLS]; void setup() { size(MAX_X, MAX_Y, P2D); smooth(); // create some balls for(int i=0; i flySteps) newTarget(); } int interpol(int source, int target, int currentStep, int totalSteps) { float v = currentStep / (float)totalSteps; // smoothstep twice v = v*v*(3-2*v); v = v*v*(3-2*v); return int(source + (target-source)*v + .5); } void newTarget() { sourceX = targetX; sourceY = targetY; targetX = (int)random(size/2, MAX_X-size/2); targetY = (int)random(size/2, MAX_Y-size/2); currentStep = 0; } }