Montag, 7. September 2015

Interactive Art: Homework 1


A simple program in processing creating a face. 
There are two functions called in mainloop every 1/60 sec. 
-One function creates a background patern with a for loop. Colors a generated random with every tick of the program.
-The other function creates a rotating creeper face.











Processing Code:

int colorR, colorG, colorB, varianz;
float counter;

public void setup()
{
  size(400,400);
  background(90,90,90,255);
  counter = 0;
}

public void draw()
{
  drawBackground();
  drawFace();
  
  pushStyle();
  fill(0);
  text("Interactive Art - Homework 1 (Martin Hanusch): \nFace (Creeper Face, Minecraft)",20,20);
  popStyle();
  
  println (frameRate); //just to check the performance
}

/*
DRAW THE Background
*/
public void drawBackground()
{
  for(int i = 0; i < 10; i++)
  {
    for(int j = 0; j < 10; j++)
    { 
      colorR = floor(random(0,100));
      colorG = floor(random(150,255));   
      colorB = floor(random(0,100));       
      pushStyle();
      noStroke();  
      fill(colorR,colorG,colorB,255);
      rect(i*40,j*40,40,40);
      popStyle(); 
    }  
  }
}

/*
DRAW THE FACE
*/
public void drawFace()
{
  counter+=0.01;
  pushMatrix();
  pushStyle();
  translate(width/2, height/2);
  rotate(counter);
  translate(-width/2, -height/2);  
  scale(1.05);
  noStroke();
  fill(0);
  rect(110,90,60,60);
  rect(230,90,60,60);
  rect(170,150,60,30);
  rect(140,180,120,60);
  rect(140,240,30,30);  
  rect(230,240,30,30);  
  popStyle();
  popMatrix();
}

Keine Kommentare:

Kommentar veröffentlichen