Rect, ellipse, point

From MideumWiki

Jump to: navigation, search


Contents

개요

2014년 11월 12일, 국립 현대미술관 서울관에서 진행된 바우하우스전시 참여작가 중 하나인, 파티의 5번의 공연중, 스크린 부분에 참여한 작업이다.

링크

플레이. 바우하우스. 페북 링크.

구성

1. 처음 10초의 목소리에 반응하는 네모,
2. 이어지는 8초 정도의 작아지는 원,
3. 그리고 1분 40초 정도의 목소리에 반응하여 방향을 바꾸는 라인

코드

import ddf.minim.*;
Minim minim;
AudioInput in;
float positionX;
float positionY;
float pPositionX;
float pPositionY;
float speedX;
float speedY;
float accelX;
float accelY;
int flag;
float rectPosX;
float rectPosY;
float rectSizeX;
float rectSizeY;
float rectStrokeColor;
float ellipseSizeX;
float ellipseSizeY;
float angle;
Timer timer1;
Timer timer2;
Timer timer3;
int time1;
int time2;
int time3;
float volume;
int sensitive1; 
int sensitive2;
void setup() {
noCursor();
((javax.swing.JFrame) frame).getContentPane().setBackground(new java.awt.Color(0,0,0));
size(900, 900);
sensitive1 = 3;
sensitive2 = 5;
positionX = width/2;
positionY = height/2;
speedX = 0;
speedY = 0;
accelX = 0;
accelY = 0;
ellipseSizeX = height/2;
ellipseSizeY = width/2;
minim = new Minim(this);
in = minim.getLineIn();
background(0);
time1 = 10;
time2 = 8;
time3 = 90;
timer1 = new Timer(time1);
timer2 = new Timer(time2);
timer3 = new Timer(time3);
flag = 0;
timer1.getStartingTime();
}
void draw() {
 timer1.calculateNowTime();
 timer2.calculateNowTime();
 timer3.calculateNowTime();
 volume = abs(in.left.get(0) * 50);
 //conditional Change
 if (flag == 0) {
   timer1.calculateSpendingTime();
   if (timer1.timePassed()) {
     flag = 1;
     timer1.resetSpendingTime();
     timer2.getStartingTime();
   }
 }
 if (flag == 1) {
   timer2.calculateSpendingTime();
   if (timer2.timePassed()) {
     flag = 2;
     timer2.resetSpendingTime();
     timer3.getStartingTime();
   }
 }
 if (flag == 2) {
   timer3.calculateSpendingTime();
   if (timer3.timePassed()) {
     flag = 3;
     timer3.resetSpendingTime();
   }
 }
 //works to do
 if (flag == 2) {//free drawing
   rectMode(LEFT);
   fill(0, 4);
   rect(0, 0, width, height);
   pPositionX = positionX;
   pPositionY = positionY;
   if (volume > sensitive1) {
     accelX = random(-(width * 2/900), (width * 2/900) );
     accelY = random(-(width * 2/900), (width * 2/900) );
     speedX = speedX + accelX;
     speedY = speedY + accelY;
     if (volume > sensitive2) {
       speedX *= -1;
       speedY *= -1;
     }
     speedX = constrain(speedX, -(width * 10/900), (width * 10/900) );
     speedY = constrain(speedY, -(width * 10/900), (width * 10/900) );
   }
   positionX = positionX + speedX;
   positionY = positionY + speedY;
   if (positionX != pPositionX) {
     stroke(255);
     strokeWeight(width * 35/900);
     line(positionX, positionY, pPositionX, pPositionY);
   }
   if (positionY != pPositionY) {
     stroke(255);
     strokeWeight(width * 35/900);
     line(positionX, positionY, pPositionX, pPositionY);
   }
   if (positionX > width) {
     positionX = 0;
   }
   if (positionY > height) {
     positionY = 0;
   }
   if (positionX < 0) {
     positionX = width;
   }
   if (positionY < 0) {
     positionY = height;
   }
 }
 if (flag == 1) {//ellipse
   rectMode(LEFT);
   fill(0, 10);
   rect(0, 0, width, height);
   noStroke();
   translate(width/2, height/2);
   //strokeWeight(65);
   fill(255);
   ellipseSizeX = ellipseSizeX + (0-ellipseSizeX)/90;
   ellipseSizeY = ellipseSizeY + (0-ellipseSizeY)/90;
   if (ellipseSizeX < 1 || ellipseSizeY < 1  ) {
     ellipseSizeX = 0;
     ellipseSizeY = 0;
   }
   //stroke(255);
   ellipse(0, 0, ellipseSizeX, ellipseSizeY);
 }
 if (flag == 0) {//rect
   rectSizeX = width* 5/9;
   rectSizeY = width* 5/9;
   angle = angle + map(volume, 0, 50, 0, 2);
   rectPosX = map(sin(angle), 0, 1, 0, 10);
   rectPosY = map(cos(angle), 0, 1, 0, 10);
   rectStrokeColor = 255;//map(timer3.spendingTime, 0, time3*1000, 255, 0);
   background(0);
   translate(width/2, height/2);
   stroke(255, rectStrokeColor);
   noFill();
   strokeWeight(width * 65/900);
   pushMatrix();
   translate(rectPosX, rectPosY);
   rectMode(CENTER);
   rect(0, 0, rectSizeX, rectSizeY);
   popMatrix();
 }
 if (flag == 3) {
   background(0);
 }
 noStroke();
 //ellipse(positionX, positionY, 6.5, 6.5);  
 println("====");
 println("flag = " + flag);
 println("accelX = " + accelX);
 println("accelY = " + accelY);
 println("speedX = " + speedX);
 println("speedY = " + speedY);
 println("ellipseSizeY = " + ellipseSizeY);
 println("timer1.nowTime = " + timer1.nowTime);
 println("timer1.spendingTime = " + timer1.spendingTime);
 println("timer2.nowTime = " + timer2.nowTime);
 println("timer2.spendingTime = " + timer2.spendingTime);
 println("timer3.nowTime = " + timer3.nowTime);
 println("timer3.spendingTime = " + timer3.spendingTime);
 println("volume = " + volume);
}
class Timer {
float startingTime;
float spendingTime;
float nowTime;
float setTime;
Timer(float valueForSetTime) {
  startingTime = 0;
  spendingTime = 0;
  nowTime = 0;
  setTime = valueForSetTime*1000;
}
void getStartingTime() {
  startingTime = millis();
}
void calculateSpendingTime() {
  spendingTime = nowTime - startingTime;
}
void calculateNowTime() {
  nowTime = millis();
}
void resetSpendingTime() {
  spendingTime = 0;
}
boolean timePassed() {
  if (spendingTime > setTime) {
    return true;
  } 
  else {
    return false;
  }
}
boolean timeBetween(int start, int end) {
  start = start * 1000;
  end = end * 1000;
  
  if (spendingTime > start && spendingTime < end) {
    return true;
  } else {
    return false;
  }
} 
}
Personal tools