Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created January 15, 2012 21:40
Show Gist options
  • Save jordanorelli/1617569 to your computer and use it in GitHub Desktop.
Save jordanorelli/1617569 to your computer and use it in GitHub Desktop.
page 84, exercise 2, "Processing: A programming Handbook..."
/* Use the data from the curve y = x ^ 8 to draw something unique */
size(640, 480);
smooth();
float expMax = 8.0;
float expStep = 0.0625;
for(int x = 0; x < width; x++) {
float xNorm = norm(x, 0, width);
noStroke();
fill(0, 20);
for(float i = 1.0; i < expMax; i+=expStep) {
float yPos = height * pow(xNorm, i);
float yNeg = height * pow(xNorm, 1.0/i);
ellipse(x, yPos, 12, 6);
ellipse(x, yNeg, 6, 12);
}
float yPos = height * pow(xNorm, expMax);
float yNeg = height * pow(xNorm, 1.0/expMax);
stroke(0);
strokeWeight(1);
line(x, yPos + 8, x, 0);
line(x, yNeg, x, height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment