ABOUT PROJECTS RESUME
nature-of-code:bernini3.pde
 
/*
int xspacing = 4;   // How far apart should each horizontal location be spaced
int w;              // Width of entire wave
 
float yoff = 0.0f;        // 2nd dimension of perlin noise
float[] yvalues;          // Using an array to store height values for the wave (not entirely necessary)
 
 
//were in setup:
w = width+16;
  yvalues = new float[w/xspacing];
*/
 
 
Wave[] Optic = new Wave[6];
 
void setup() {
  size(400,400);
  framerate(50);
  colorMode(RGB,255,255,255,100);
  smooth(); 
 
  //Wave(int xs, int ww, float[] yv)
  Optic[0] = new Wave(4, width + 56, 1, 100);
  Optic[1] = new Wave(4, width + 56, 1, 300);
  Optic[4] = new Wave(8, width + 56,0, 180);
  Optic[5] = new Wave(4, width + 56, 1, 220);
  Optic[2] = new Wave(12, width + 56,0, 180);
  Optic[3] = new Wave(16, width + 56, 1, 220);
 
}
 
 
void draw() {
  background(255);
 
  for(int i = 0; i < Optic.length; i++){
    Optic[i].smor();
  }
}
 
/*
Thing t;
Liquid[] Spills = new Liquid[7];
boolean showVectors = true;
 
void setup() {
  size(200,200);
  framerate(30);  
  smooth();
  background(0);
  colorMode(RGB,255,255,255,100);
  Vector3D a = new Vector3D(0.0,0.0);
  Vector3D v = new Vector3D(0.0,0.0);
  Vector3D l = new Vector3D(10,0);
  t = new Thing(a,v,l,1.5);
  //Liquid(xls, yls, lw, lh, d, r, g, b)
  Spills[0] = new Liquid(0, 40, 40, 50, -0.05, 30, 150, 150);
  Spills[1] = new Liquid(0, 70, 50, 80, -0.07, 42, 255, 200);
  Spills[2] = new Liquid(0, 90, 60, 100, -0.09, 255, 175, 0);
  Spills[3] = new Liquid(0, 110, 70, 120, -0.1, 176, 75, 56);
  Spills[4] = new Liquid(0, 130, 80, 140, -0.2, 255, 175, 200);
  Spills[5] = new Liquid(0, 150, 90, 160, -0.8, 0, 100, 130);
  Spills[6] = new Liquid(180, 180, 210, 210, -1.0, 100, 255, 6);
}
 
void draw() {
  background(0);
 
  // Add gravity to thing
  // This isn't "real" gravity, just a made up force vector
  Vector3D grav = new Vector3D(0,0.08);
  t.add_force(grav);
 
  // Add wind to thing
  // Again, just making up a force vector
  Vector3D wind = new Vector3D(0.05,0.0);
  t.add_force(wind);
 
 
  for(int i = 0; i < Spills.length; i++){
    Spills[i].pour();
  }
 
  t.go();
 
 
  /*
  // Draw the "liquid"
  // Note it would probably be a good idea to make a liquid class
  noStroke();
  fill(200,50);
  rectMode(CORNER);
  rect(0,liq_start,width,liq_height);// * /
}
 
 
// Renders a vector object 'v' as an arrow and a location 'loc'
void drawVector(Vector3D v, Vector3D loc, float scayl) {
  pushMatrix();
  float arrowsize = 4;
  // Translate to location to render vector
  translate(loc.x,loc.y);
  stroke(255);
  // Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate
  rotate(v.heading2D());
  // Calculate length of vector & scale it to be bigger or smaller if necessary
  float len = v.magnitude()*scayl;
  // Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction)
  line(0,0,len,0);
  line(len,0,len-arrowsize,+arrowsize/2);
  line(len,0,len-arrowsize,-arrowsize/2);
  popMatrix();
}
 
 
void mousePressed() {
  showVectors = !showVectors;
}
 
 
 
 
*/
Show pagesource Old revisions Backlinks Index Recent changes
nature-of-code/bernini3.pde.txt · Last modified: 2009/04/26 01:30 (external edit)