new ipad act

The iPad act was a custom creation, made to be performed in the Stockholm booth at MIPIM trade show in Cannes. It was commissioned by lovely bureau Step2 Communications and the brief was to create a visual, magical and striking presentation about Stockholm using modern technology.

http://d1gits.com/

Toyo Ito Serpentine Gallery Pavilion (2002)

this short code show how the rotation of the retangle. also we can see the whole creation of the ito’s pavilion in London. it is a new method for the creatio of architecture.

void setup(){
rectMode(CENTER);
noFill();
size(300,300);

}

void draw (){
  background(255);
for(float i=0; i<30; i++){
  pushMatrix();
  translate(width/2,height/2);
  scale(1/(i/mouseX),1/(i/mouseY));
  rotate(radians(i*mouseX*10));
  rect(0,0,50,50);
  popMatrix();
}
}

share small game

this show the small ball eat other ball smaller that itself, and then it will become bigger, or when it meet the ball bigger that itself, then game over. using mouse to control the ball.

float x;
float y;
float easing = 0.01;
int r = 10;
int gameCase = 1;
float[] bugx = new float [20];
float[] bugy = new float [20];
int[] bugr = new int [20];
float[] speedx = new float [20];
float[] speedy = new float [20];
float a = 0.05;

void setup() {
size (800, 600);
smooth();
ellipseMode (CENTER);
for (int i=0; i<20; i++) {
bugx[i] = random (0, width);
bugy[i] = random (0, height);
bugr[i] = int (random (0, 30));
}
x = random (0, width);
y = random (0, height);
}

void draw() {
background (73, 125, 178);
noStroke();
fill (0);
for (int i=0; i<20; i++) {
ellipse (bugx[i], bugy[i], bugr[i]*2, bugr[i]*2);
}
fill (254, 252, 150);
ellipse (x, y, r*2, r*2);
for (int i=0; i<20; i++) {
float z=(bugx[i]-x)*(bugx[i]-x)+(bugy[i]-y)*(bugy[i]-y)-(bugr[i]+r)*(bugr[i]+r);
if (z<0 && bugr[i]>r) {
gameCase = 0;
}
}
if (gameCase == 0) {
gameover();
} else {
float targetX = mouseX;
float targetY = mouseY;
x += (targetX – x) * easing;
y += (targetY – y) * easing;
for (int i=0; i<20; i++) {
move (i);
}
}
for (int i=0; i<20; i++) {
if ((bugx[i]-x)*(bugx[i]-x)+(bugy[i]-y)*(bugy[i]-y)-(bugr[i]+r)*(bugr[i]+r)<0 && bugr[i]<r) {
r = int (sqrt (r*r + bugr[i]*bugr[i]));
bugr[i] = 0;
}
}
int sum = 100;
for (int i=0; i<20; i++) {
sum += bugr[i];
}
if (sum == 100) {
win();
}
}
void move(int i) {
speedx[i] += random (-a, a);
speedy[i] += random (-a, a);
bugx[i] += speedx[i];
bugy[i] += speedy[i];
if (bugx[i]<-10) {
bugx[i] += width;
}
if (bugx[i] > width+10) {
bugx[i] -= width;
}
if (bugy[i] < -10) {
bugy[i] += height;
}
if (bugy[i] > height+10) {
bugy[i] -= height;
}
}
void gameover() {
fill (240, 40, 40);
textSize (65);
textAlign(CENTER);
text (“Game Over”, width/2, height/2);
}
void win() {
fill (255);
textSize (65);
textAlign(CENTER);
text (“Congratulation!”, width/2, height/2);
textSize (30);
text (“Bacterial Cleared!”, width/2, height/2+50);
}

other exercise 1

int sx, sy;
float density =0.1;
int[][][] world;
int d=10;

void setup() {
  size(1000, 600, P2D);
  frameRate(10);
  sx = width;
  sy = height;
  world = new int[sx][sy][2];
 
  
  // Set random cells to ‘on’
  for (int i = 0; i < sx * sy * density; i+=d) {
    world[d*int(random(sx/d))][d*int(random(sy/d))][1] = 1;
  }
}

void draw()
{
background(0);
for(int a=5;a<sx;a+=d){
    stroke(20);
    line(a,0,a,sy);
    line(0,a,sx,a);
  }
   // Drawing and update cycle
  for (int x = 0; x < sx; x=x+d) {
    for (int y = 0; y < sy; y=y+d) {
      //if (world[x][y][1] == 1)
      // Change recommended by The.Lucky.Mutt
      if ((world[x][y][1] == 1) || (world[x][y][1] == 0 && world[x][y][0] == 1))
      {
        world[x][y][0] = 1;
   for (int i = -d/2; i < d/2; i++) {
    for(int j = -d/2; j < d/2; j++) {
    set(x+i, y+j, #ffff35);
  }
}
      }
     
      if (world[x][y][1] == -1)
      {
        world[x][y][0] = 0;
      }
      world[x][y][1] = 0;
    }
  }
  // Birth and death cycle
  for (int x = 0; x < sx; x=x+d) {
    for (int y = 0; y < sy; y=y+d) {
      int count = neighbors(x, y);
      if (count == 3 && world[x][y][0] == 0)
      {
        world[x][y][1] = 1;
      }
      if ((count < 2 || count > 3) && world[x][y][0] == 1)
     {
        world[x][y][1] = -1;
      }
    }
  }
}

// Count the number of adjacent cells ‘on’
int neighbors(int x, int y)
{
  return world[(x + d) % sx][y][0] +
         world[x][(y + d) % sy][0] +
         world[(x + sx – d) % sx][y][0] +
         world[x][(y + sy – d) % sy][0] +
         world[(x + d) % sx][(y + d) % sy][0] +
         world[(x + sx – d) % sx][(y + d) % sy][0] +
         world[(x + sx – d) % sx][(y + sy – d) % sy][0] +
         world[(x + d) % sx][(y + sy – d) % sy][0];
}
        
 
void mouseClicked() {
  int a=int(mouseX);
  int b=int(mouseY);
  if (a%10<=5 && b%10<=5 ){
world[a-a%10][b-b%10][0]=1;
  }
  if (a%10<=5 && b%10>5 ){
world[a-a%10][b-b%10+10][0]=1;
  }
  if (a%10>5 && b%10<=5 ){
world[a-a%10+10][b-b%10][0]=1;
  }
  if (a%10>5 && b%10>5 ){
world[a-a%10+10][b-b%10+10][0]=1;
  }
}

assignment 4(1)

void setup(){
  size(300,300);
 frameRate(30) ;
}

float x,y;

void draw(){
  //background(255);
  x = x + random(-3,3);
  y = y + random(-3,3);
  constrain(x,100,200);
  constrain(y,100,200);
  ellipse(x,y,20,20);
}

void mousePressed(){
  x = mouseX;
  y = mouseY;
}

assignment 2

int num = 20;
int[] dx = new int[num];
int[] dy = new int[num];
void setup() {
size(300, 240);
for (int i = 0; i < num; i++) {
dx[i] = i * 5;
dy[i] = 12 + (i * 6);
}
}

void draw() {
background(0);
smooth();
for (int i = 0; i < num; i++) {
dx[i] = dx[i] + 1;
height=dx[i]-5;
width =dy[i]-10;
if (dx[i] > 100) {
dx[i] = -100;
}
rect(dx[i], dy[i],height,width);
}
}