Monday, April 27, 2015

Processing Papan Catur

Papan Catur sederhananya mba agnes :p

Berikut adalah sourcenya :
void setup(){
  size(500,500);
}
void draw(){
  fill(0);
  rect(0,0,500,500);
  fill(255);
  for(int i=0; i<500; i+=100){
    for(int j=0; j<500; j+=100){
      rect(i,j,50,50);
      rect(i+50,j+50,50,50);
    }
  }
  int a=second();
  pushMatrix();
  translate(25*a,0);
  //lingkaran merah
  noStroke();
  fill(255,0,0);
  ellipse(25,25,30,30);
  popMatrix();
  int b=second();
  pushMatrix();
  translate(20*b,0);
  //lingkaran kuning
  noStroke();
  fill(255,255,0);
  ellipse(75,125,30,30);
  popMatrix();
  int c=second();
  pushMatrix();
  translate(15*c,0);
  //lingkaran hijau
  noStroke();
  fill(128,255,0);
  ellipse(125,225,30,30);
  popMatrix();
  int d=second();
  pushMatrix();
  translate(10*d,0);
  //lingkaran biru
  noStroke();
  fill(0,0,255);
  ellipse(175,325,30,30);
  popMatrix();
  int e=second();
  pushMatrix();
  translate(5*e,0);
  //lingkaran orange
  noStroke();
  fill(255,128,0);
  ellipse(225,425,30,30);
  popMatrix();
}

Berikut hasilnya :

## Semoga Bermanfaat ##

1 comment: