As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Saturday, October 6, 2018

Color the Background, fast!

This program allows to paint with red color on the black background. Eventually, the red paint will disappear, which is controlled by the frame rate. The goal of the program to color the background as fast as possible (Photo 1).


Photo 1: Coloring the Background.

To make this working, I changed the initial frame rate for slowing it down. I also adjusted the canvas' size and the colors (black and red accordingly). Finally, I defined the text as input type and its size.

Here's the code:

//Modified by: Aleksei Zhurankou

int num = 900; //setting frame ratenumber
float mx[] = new float[num]; //defining array to store mouse's x position
float my[] = new float[num]; //defining array to store mouse's y position

void setup() {
  size(400, 320); //defining canvas size
  fill(255, 0, 0); //setting paint color to red
}

void draw() {
  background(0); //setting bg color to black

  int which = frameCount % num;
  mx[which] = mouseX; //assigning array values to mouse x position
  my[which] = mouseY; //assigning array values to mouse y position

  for (int i = 0; i < num; i++) { //assigning xy values with for-loop
    int index = (which+1 + i) % num;
    textSize(48); //setting text size
    text("RED", mx[index], my[index]); //rendering current mouse position with text
  }
}

No comments:

Post a Comment