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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Ira Greenberg, 2/12/07<br />

********************************************/<br />

float baseX1, baseY1, baseX2, baseY2;<br />

float baseLength;<br />

float[] xCoords, yCoords;<br />

float ellipseX, ellipseY, ellipseRadius = 8;<br />

float directionX, directionY;<br />

float ellipseSpeed = 3.5;<br />

float velocityX, velocityY;<br />

void setup(){<br />

size(400, 400);<br />

fill(128);<br />

smooth();<br />

baseX1 = 0;<br />

baseY1 = height-150;<br />

baseX2 = width;<br />

baseY2 = height;<br />

// start ellipse at middle top of screen<br />

ellipseX = width/2;<br />

// calculate initial r<strong>and</strong>om direction<br />

directionX = r<strong>and</strong>om(.1, .99);<br />

directionY = r<strong>and</strong>om(.1, .99);<br />

// normalize direction vector<br />

float directionVectLength = sqrt(directionX*directionX + ➥<br />

directionY*directionY);<br />

directionX /= directionVectLength;<br />

directionY /= directionVectLength;<br />

}<br />

void draw(){<br />

// draw background<br />

fill(0, 6);<br />

noStroke();<br />

rect(0, 0, width, height);<br />

// calculate length of base top<br />

baseLength = dist(baseX1, baseY1, baseX2, baseY2);<br />

xCoords = new float[ceil(baseLength)];<br />

yCoords = new float[ceil(baseLength)];<br />

// fill base top coordinate array<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!