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.

Thursday, April 11, 2013

Karin Hellman // Processing - Patterns

I created a snippet of code that draws ellipses on the screen every time the uses clicks the mouse. The color, opacity, size and position is randomized with each click. Results look kinda like wallpapers from the 50's.





/*
   - Processing wallpaper creator
   - Karin Hellman 
*/

 //Variables used
 public int w = 800; //Screen width
 public int h = 600; //Screen height
 public float sizeX; //Ellipse x radi
 public float sizeY; //Ellipse Y radi
 public float r;
 public float g;  //rgb values
 public float b;

void setup(){
  size(w,h);  //the size of the output screen
  background(255,255,255); 
  noStroke();
 } 

void draw(){
}

//Changes the color and size of the ellipses
//every time the mouse is clicked
void mouseClicked(){
  sizeX = randVal(w/4, w); //ellipse's max radi 1/4 
  sizeY = randVal(h/4, h); //of the screen width/height
  r = random(255);
  g = random(255);
  b = random(255);
  fill(r,g,b,random(50,200)); //random the alpha each time

  //specifys how to draw the ellipses
  int[] f = {CENTER, RADIUS, CORNER};   
  int n = int(random(f.length));
  ellipseMode((f[n]));

  //Draws a pattern of transparent ellipses covering the screen      
  for (int i = 0; i < w+sizeX; i=i+int(sizeX)){
    for (int j = 0; j < h+sizeY; j=j+int(sizeY)){
      ellipse(i, j, sizeX, sizeY);
    }
  }
  
}

//function that returns the ellipses' radii
float randVal(float rMax, float max){
  float r = random(10, rMax);
  r = rMax/round(rMax/r);
  return r;
  
}


No comments:

Post a Comment