sbisker – project 0

by sbisker @ 8:20 pm 12 January 2010

Part A – Noll Knockoff

GDE Error: Unable to load profile settings
```import processing.pdf.*;   //Project 0 //Solomon Bisker   //Some code adapted from Sine Wave example at processing.org //by Daniel Shiffman (since a the fastest way to learn an API is to study //someone else's code)   int xspacing = 1; // Initial spacing difference (base value for dx) int w; // Width of entire wave   int yoffset = 5; //Spacing between horizontal waves, in pixels   float theta = 0.0; // Start angle at 0 float amplitude = 75.0; // Height of wave float baseperiod = 100.0; // How many pixels in a full cycle for first period float dx; // Intermediate value for incrementing X (recalculated each time) float[] yvalues; // Using an array to store height values for the wave   void setup() { size(800,800); noLoop(); beginRecord(PDF, "nollknockoff.pdf"); smooth(); w = width; //Calculate initial dx (with period of 1) dx = (TWO_PI / baseperiod) * xspacing ; yvalues = new float[800]; }   void draw() { //Let's just calculate the wave once and draw it 90 times. //Seems faster.   //First, calculate and store the wave values calcWave();   //Now, we draw the wave 90 times. //i simply tells us which wave it is (triggering appropriate //horizontal offset in its rendering) for (int i=0; i &lt; 90; i++){ renderWave(i); } //Stop writing to PDF; finish saving PDF. endRecord(); }     void calcWave() {   // For every x value, calculate a y value with sine function float x = theta;   //We create the &quot;increasing period&quot; by calcuating the regular value of //a normal sine function, but just offsetting x each time a linear amount //and using interpolation between each point (curveVertex).   for (int j = 0; j &lt; yvalues.length; j++) { //Store that calcuated value yvalues[j] = sin(x)*amplitude;   dx = (TWO_PI / baseperiod) * xspacing / (float) (1+(float) j/100) ; x+=dx; }   }     void renderWave(int i) { // A simple way to draw the wave with an ellipse at each location //We draw the waves from page top, downward as i increases   //For each x,y pair in the function, draw a point, with y value //offset by i times some y offset constant...   noFill(); beginShape(); for (int x = 0; x &lt; yvalues.length; x++) { curveVertex(x*xspacing,i*yoffset+amplitude+yvalues[x]); } endShape();   }```

Part B – Pong

It doesn’t seem to like this whole embed thing, so here’s the link to the index page:

Pong (In Stunning Terminal Green)