3D

float a, b, c;
void setup() {
  a = b = c = 4.0;
  size(400, 400, P3D);
  frameRate(30);
}

void draw() {
  background(200);

  ambientLight(102, 102, 102);
  lightSpecular(204, 204, 204);
  directionalLight(102, 102, 102, 0, 0, -1);
  specular(255, 255, 255);
  shininess(3.0);

  pushMatrix();
    translate(width/2, height/2);
    rotateY(mouseX * 0.02);
    rotateZ(mouseY * 0.02);
    scale(20);

    stroke(0);
    noStroke();
    translate(1, 3);
    box(3);
    translate(-1,3);
    sphere(2);

    beginShape(TRIANGLES);
    fill(128);
    vertex(a, b, c);
    vertex(a, -b, c);
    vertex(a, -b, -c);

    vertex(a, -b, -c);
    vertex(a, -b, c);
    vertex(-a, b, -c);

    vertex(-a, b, -c);
    vertex(a, -b, c);
    vertex(a, b, c);

    vertex(a, b, c);
    vertex(a, -b, -c);
    vertex(-a, b, -c);

    endShape(CLOSE);

  popMatrix();
  changeValues();

}

void changeValues() {
  switch(int(random(0, 3))) {
   case 0: a+= 0.01;
     break;
   case 1: b+= 0.02;
     break;
   case 2: c+= 0.03;
     break;
  }
}

bene posted on May 4th, 2008   Add comment

3D

float a, b, c;
void setup() {
  a = b = c = 4.0;
  size(400, 400, P3D);
  frameRate(30);
}

void draw() {
  background(200);

  ambientLight(102, 102, 102);
  lightSpecular(204, 204, 204);
  directionalLight(102, 102, 102, 0, 0, -1);
  specular(255, 255, 255);
  shininess(3.0);

  pushMatrix();
    translate(width/2, height/2);
    rotateY(mouseX * 0.02);
    rotateZ(mouseY * 0.02);
    scale(20);

    stroke(0);
    noStroke();
    translate(1, 3);
    box(3);
    translate(-1,3);
    sphere(2);

    beginShape(TRIANGLES);
    fill(128);
    vertex(a, b, c);
    vertex(a, -b, c);
    vertex(a, -b, -c);

    vertex(a, -b, -c);
    vertex(a, -b, c);
    vertex(-a, b, -c);

    vertex(-a, b, -c);
    vertex(a, -b, c);
    vertex(a, b, c);

    vertex(a, b, c);
    vertex(a, -b, -c);
    vertex(-a, b, -c);

    endShape(CLOSE);

  popMatrix();
  changeValues();

}

void changeValues() {
  switch(int(random(0, 3))) {
   case 0: a+= 0.01;
     break;
   case 1: b+= 0.02;
     break;
   case 2: c+= 0.03;
     break;
  }
}

bene posted on May 4th, 2008   Add comment

Audio

import ddf.minim.*;
import ddf.minim.analysis.*;

AudioPlayer buddha;
BeatDetect beat;
float eRadius;

void setup() {
  size(300, 300);
  Minim.start(this);
  buddha = Minim.loadFile("RockTheCasbah.wav");
  buddha.play();
  beat = new BeatDetect();
  eRadius = 20;
}

void draw() {
//  background(0);
  fill(0, 50);
  noStroke();
  rect(0, 0, width, height);
  smooth();
  stroke(255);
  for(int i = 0; i < buddha.bufferSize() - 1; i++)
  {
    line(i, 50 + buddha.left.get(i)*250, i+1, 50 + buddha.left.get(i+1)*250);
    line(i, 250 + buddha.right.get(i)*250, i+1, 250 + buddha.right.get(i+1)*250);
  }

  beat.detect(buddha.mix);
  float a = map(eRadius, 20, 80, 60, 255);
  fill(60, 255, 0, a);
  if ( beat.isOnset() ) eRadius = 280;
  ellipse(width/2, height/2, eRadius, eRadius);
  eRadius *= 0.95;
  if ( eRadius < 20 ) eRadius = 20;
}

void stop()
{
  // an AudioPlayer you got from Minim.loadFile()
  buddha.close();
  // an AudioInput you got from Minim.getLineIn()
  //input.close();
  super.stop();
}

bene posted on April 29th, 2008   Add comment

File Processing

source code

text file contains:
45 123
2 345
56 34
8 3234
34 55
700 2

bene posted on April 24th, 2008   Add comment

Files for 4/22

peep
peep alpha
map

peeps code
weather code

bene posted on April 22nd, 2008   Add comment

Final Project: Data Visualization

For your final project, you are to create a data visualization based on your own set of data. The goal is to create a visual space that abstracts a set of information.

You can use any set of data you choose: what you have for breakfast each day, the temperature, a daily rating of your mood, etc. If you would like to use personal data, you should probably start building it now. If you would like to tap into the internet, there is an XML parsing library.

You are not making a pie chart, bar graph, spreadsheet, etc! You should create an interesting aesthetic metaphor to express your data in.

Inspiration:

  1. information aesthetics
  2. data is nature
  3. rhizome
  4. 175 data visualizations

Due May 8th.

bene posted on April 17th, 2008   Add comment

Transform: rotating squares

void setup() {
  size(300, 300);
}

void draw() {
  background(0);
  fill(255);
  noStroke();
  smooth();
  frameRate(30);

  pushMatrix();
    translate(width/2, height/2);
    rotate(TWO_PI/30 * frameCount%60 * 0.5);
    //println(TWO_PI/30 * frameCount%60 * 0.5);
    rectMode(CENTER);
    rect(0, 0, 150, 150);
  popMatrix();

  pushMatrix();
    translate(width/2, height/2);
    rotate(-TWO_PI/30 * frameCount%30);
    fill(255, 0, 255);
    rect(0, 0, 50, 50);
  popMatrix();

}

bene posted on April 10th, 2008   Add comment

Matrix Manipulation

float angle;

void setup() {
  size(600, 600);
  smooth();
}

void draw() {
  background(200);

  pushMatrix();
  // moves origin to center of screen
    translate(width/2, height/2);
    rotate(frameCount * 0.01);
    scale(frameCount%200 * 0.01);
    angle = 0;

    for(int i=0; i<10; i++) {
      pushMatrix();
        rotate(angle);
        line (width/2 - 20, 0, width/2, frameCount%200*3);
        ellipse(width/2 - 20, 0, 30, 30);
      popMatrix();
      angle += TWO_PI / 10;
    }
  popMatrix();
}

bene posted on April 8th, 2008   Add comment

Color Bars

movingBars

final int numBars = 20; ColorBar[] bars = new ColorBar[numBars]; int RandInt (int minVal, int maxVal) { return int(random(minVal, maxVal+1)); } void setup() { size(600, 300); colorMode(HSB, 360); frameRate(30); for (int i=0; i < numBars; i++) { bars[i] = new ColorBar(RandInt(240, 360), RandInt(minWidth, maxWidth)); } } void draw() { background(0); for (int i=0; i < numBars; i++) { bars[i].drawBar(); } if ( (frameCount % 450 == 0) && (frameCount % 900 != 0) ) { // println("CHANGE!"); for (int i=0; i < numBars; i++) { bars[i].updateSpeed(1, RandInt(2, 4)); } } if (frameCount % 900 == 0) { // println("CHANGE!"); for (int i=0; i < numBars; i++) { bars[i].updateSpeed(1, RandInt(5, 7)); } } }

ColorBar

final int minWidth = 1;
final int maxWidth = 30;

class ColorBar {
  float x; // x position
  int w; // width of bar
  float speed; // rate of motion
  color c; // bar color

  ColorBar (int barHue, int barWidth) {
    x = RandInt(0, width-barWidth);
    w = barWidth;
    speed = map(w, minWidth, maxWidth, 4, 1);
    float a = map(barWidth, minWidth, maxWidth, 360, 120);
    c = color (barHue, 360, 360, a);
  }

  void drawBar() {
    noStroke();
    fill(c);
    rect(x, 0, w, height);
    moveBar();
  }

  void moveBar() {
//    if (frameCount % speed == 0) {
      x += speed;
      if (x > width)
        x = 0 - w;
//    }
  }  

  void updateSpeed (int newMin, int newMax) {
    speed = map (w, minWidth, maxWidth, newMax, newMin);
  }
}

bene posted on April 1st, 2008   Add comment

creating polygon objects

Writing a class to define a flexible polygon object.
polyDrawing.txt
class Polygon

bene posted on March 27th, 2008   Add comment

Previous Posts


Pages

Categories

Links

Feeds