Plan a conversation

As a challenge for the weekend Vitor gave us the following exercise.

I decided to use my programming knowledge to create an abstract visualization of the conversation. Since programming is something I want to further work with this year, and we had worked with it before I landed on using Processing to visualize my conversation.

The top part represents the person I’m talking to, the bottom is my responses. Each blip up and down represents a word. The longer the blip, the longer the word.

Below is the code I created to make this work. I used this example code from the Processing documentation as a starting point.

//creates two arrays to later graph the mouse button press values
int[] rvals;
int[] lvals;

void setup() {
  size(800, 100);
  
  //sets array length to the width of the screen
  lvals = new int[width];
  rvals = new int[width];
}

void draw() {
  background(color(105,105,105));

  //loops through the array values
  for (int i = 1; i < width; i++) { 
    lvals[i-1] = lvals[i];
    rvals[i-1] = rvals[i];
  }
  
  //checks left mouse button
  if (mousePressed == true && (mouseButton == LEFT)) {
    lvals[width-1] = 4;
  } else {
    lvals[width-1] = (height/2)-1;
  }

  //checks right mouse button  
  if (mousePressed == true && (mouseButton == RIGHT)) {
    rvals[width-1] = (height/2)-4;
  } else {
    rvals[width-1] = 0;
  }
  
  // Draw the mouse presses 
  for(int i = 1; i < width; i++) {
 
    //Left mouse
    stroke(color(255, 178, 80));
    line(i, lvals[i], i, lvals[i-1]);
    
    //Right mouse
    stroke(color(255, 250, 205));
    line(i, height/2 + rvals[i], i, height/2 + rvals[i-1]);  
  }
  
  //saves the individual frame to a png file, to later create a GIF
  saveFrame("conv####.png");
}

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.