Showing posts with label Grafkom. Show all posts
Showing posts with label Grafkom. Show all posts

Wednesday, May 20, 2015

Latihan membuat bola memantul yang berada di dalam kotak dan bisa di lihat dari berbagai sisi dengan cara menggerakkan / menekan mouse :

berikut source codenya :

                        float  speed = 1 / .0125, range = .125, y=0;
                        boolean jalan;
                       float rx = PI / 6, ry = -PI / 6, rmax = PI / 240;
 
                        void setup () {
                                 size (256, 256, P3D);
                         }
   
                        void draw () {
                                 background (255);
   
                        if (!mousePressed) {
                            speed = constrain (dist (128, 128, mouseX, mouseY) / 128, 0, 1) * .02;
                            range = pow (constrain (dist (128, 128, mouseX, mouseY) / 128, 0, 1), 2) * .65;
                        } else {
                            rx = rx + (mouseX - pmouseX) * PI / width;
                            ry = constrain (ry - (mouseY - pmouseY) * PI / height, -HALF_PI, HALF_PI);
                    }
   
                       translate (128, 128, -192);
                       rotateX (ry);
                       rotateY (rx);
                       noFill ();
                       stroke (0, 0, 0, 31);
                       box (256, 256, 256);
   
                       if (y==-60) {
                           jalan=false;
                 };
                   if (y==60) {
                          jalan=true;
                 };
   
                 if(!jalan)
                  y=y+1;
                  else
                 y=y-1;
 
                 translate(0, y);
                 sphere(50);
        }

berikut adalah tampilannya :

========================================================================
** SEMOGA BERMANFAAT :) **

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 ##

Processing Kota yang cukup indah

Mobil-mobilannya mba agnes :p

Berikut sourcenya :
void setup(){
size (600, 600);
//latar belakang
}

void draw ()
{
noStroke();
fill(176, 244, 230);
rect(0,0,600,200);
int d;
d=second();
noStroke();
//matahari
pushMatrix();
translate(80, 60);
rotate(radians(0));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(15));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(30));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(45));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(60));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(75));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(90));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(105));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(120));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(135));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(0));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(150));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(165));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(180));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(195));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(210));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(225));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(240));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(255));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(270));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(285));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(300));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(315));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(330));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(345));
fill(255, 215, 0);
rect(0, 0, 10, 50);
popMatrix();

pushMatrix();
translate(80, 60);
rotate(radians(360));
fill(255, 255, 0);
rect(0, 0, 10, 50);
popMatrix();

fill (255, 165, 0);
ellipse(80,60,75,75);
fill (255, 255, 0);
ellipse(80,60,25,25);

//awan
fill(255);
pushMatrix();
translate(10+5*d,0);
ellipse(100,20,50,30);
ellipse(120,30,70,30);
ellipse(80,30,70,40);

ellipse(220,70,50,30);
ellipse(240,80,70,30);
ellipse(200,80,70,40);
popMatrix();
 
 
// gunung
beginShape(TRIANGLE_STRIP);
noStroke();
fill(30,144,255);
vertex(100, 200);
vertex(340, 50);
vertex(500, 200);
vertex(0, 200);
vertex(240, 50);
vertex(500, 200);

//pohon
beginShape(TRIANGLE_STRIP);
noStroke();
fill(30,144,255);
vertex(100, 200);
vertex(340, 50);
fill(128,64,0);
rect(580,75,80,127);
fill(0,128,64);
ellipse(500,30,50,50);
ellipse(510,50,50,50);
ellipse(540,20,50,50);
ellipse(550,60,50,50);
ellipse(560,10,50,50);
ellipse(510,20,50,50);
ellipse(580,30,100,100);
ellipse(590,40,100,100);
ellipse(620,40,100,100);
ellipse(590,60,50,50);
ellipse(570,70,80,80);
ellipse(560,100,50,50);
ellipse(520,100,50,50);
ellipse(530,80,50,50);

//laut
noStroke();
fill(0, 191, 255);
rect(0,250,600,75);
fill(30, 144, 255);
rect(0,325,600,25);
fill(100, 149, 237);
rect(0,350,600,75);
fill(0);
rect(0,425,600,25);
fill(255, 222, 173);
rect(0,200,600,100);
fill(255, 222, 173);
rect(0,450,600,100);

//air
fill(255); rect(0,360,100,2);
fill(255); rect(70,380,70,2);
fill(255); rect(210,410,120,2);
fill(255); rect(270,380,70,2);
fill(255); rect(480,380,200,2);

//bendera Indonesia vs Jepang
fill (0); rect (80, 125, 10, 140);
fill (0); rect (65, 265, 40, 30);
fill (255, 0, 0); rect (90, 125, 70, 25);
fill (255); rect (90, 150, 70, 25);

fill (0); rect (505, 125, 10, 140);
fill (0); rect (490, 265, 40, 30);
fill (255, 0, 0); rect (515, 125, 70,50);
fill (255, 255, 0); ellipse ( 550, 150, 30, 30);

// tugu
fill (0); rect (240, 85, 110, 20);
fill (255); rect (240, 105, 110, 20);
stroke(255,0,0);
fill (0); rect (230, 85, 10, 120);
fill (0); rect (350, 85, 10, 120);
fill (0); rect (220, 180, 150, 30);
fill (0); rect (195, 200, 200, 30);
fill (0); rect (168, 225, 255, 30);
fill (0); rect (148, 245, 295, 30);

// ekor hiu
noStroke();
fill(0); arc(100,405,70,120,3,4.5);
fill(0); arc(250,355,70,120,3,4.5);
fill(105); ellipse (200, 355, 120, 60);
fill(0); ellipse (200, 355, 110, 50);
fill(255); ellipse (160, 350, 5, 5);
fill(0);
arc(450,405,70,120,3,4.5);

//pagar
fill(128,64,0);
stroke(0);
rect(13,370,29,130);
rect(160,370,29,130);
rect(360,370,29,130);
rect(560,370,29,130);
rect(0,400,195,50);
rect(355,400,255,50);
noStroke();
triangle(28,350,5,370,50,370);
triangle(175,350,153,370,195,370);
triangle(375,350,353,370,395,370);
triangle(575,350,553,370,595,370);
fill(0);
arc(27,428,10,10,(0*PI)/180,(360*PI)/180);
arc(177,428,10,10,(0*PI)/180,(360*PI)/180);
arc(375,428,10,10,(0*PI)/180,(360*PI)/180);
arc(575,428,10,10,(0*PI)/180,(360*PI)/180);

// jalan
fill(69);
noStroke();
rect(0,510,600,100); fill(169,82,45);
rect(0,501,600,20);
fill(255);
rect(0,585,80,20);
rect(130,585,120,20);
rect(290,585,120,20);
rect(500,585,120,20);

//mobil 1
translate(10+5*d,30);
pushMatrix();
fill (0);
beginShape();
vertex(75,500);
vertex(125,450);
vertex(225,450);
vertex(275,500);
vertex(325,500);
vertex(365,520);
vertex(365,520);
vertex(365,550);
vertex(75,550);
endShape(CLOSE);
fill(0);
ellipse(140,550,50,50);
ellipse(280,550,50,50);
fill (255);
rect(120,470,40,40);
rect(190,470,40,40);
popMatrix();

// mobil 2
translate(10+5*d,30);
pushMatrix();
fill (221, 0 , 0);
beginShape();
vertex(75,500);
vertex(125,450);
vertex(225,450);
vertex(275,500);
vertex(325,500);
vertex(365,520);
vertex(365,520);
vertex(365,550);
vertex(75,550);
endShape(CLOSE);
fill(0);
ellipse(140,550,50,50);
ellipse(280,550,50,50);
fill (0);
rect(120,470,40,40);
rect(190,470,40,40);
popMatrix();
}

Berikut tampilannya :

## Semoga Bermanfaat ##

Processing Robot

Robotnya mba Agnes :p


Berikut adalah sourcenya :

size(500,600);
//background
fill(223, 247, 174);
rect(0, 0, 500, 250);
noStroke();
fill(100);
rect(0, 250, 500, 200);
fill(255);
rect(0, 350, 100, 20);
fill(255);
rect(125, 350, 100, 20);
fill(255);
rect(255, 350, 100, 20);
fill(255);
rect(395, 350, 100, 20);
fill(0);
rect(0, 450, 500, 200);
fill(160, 90, 10);
rect(0, 0, 40, 250);
fill(160, 90, 10);
rect(280, 0, 40, 250);
fill(160, 90, 10);
rect(200, 0, 40, 250);
fill(160, 90, 10);
rect(100, 0, 40, 250);
fill(160, 90, 10);
rect(450, 0, 40, 250);
fill(160, 90, 10);
rect(380, 0, 40, 250);


//pesawat
noStroke();
fill(0);
ellipse(305, 55, 140, 80);
fill(255, 128, 128);
ellipse(325, 95, 100, 60);
fill(255, 128, 128);
ellipse(355, 25, 80, 45);
fill(255, 0, 0);
ellipse(305, 55, 100, 80);
fill(0);
rect(280, 35, 25, 35);
fill(0);
rect(310, 35, 25, 35);
fill(255);
rect(310, 35, 25, 15);
fill(255);
rect(280, 35, 25, 15);
fill(255);
rect(0, 405, 20, 45);
fill(0);
rect(45, 405, 20, 45);
fill(255);
rect(100, 405, 20, 45);
fill(20);
rect(185, 405, 20, 45);
fill(255);
rect(255, 405, 20, 45);
fill(0);
rect(325, 405, 20, 45);
fill(255);
rect(395, 405, 20, 45);
fill(0);
rect(485, 405, 20, 45);

//DRAW KEPALA
stroke (255, 170, 130);
strokeWeight(80);
strokeCap(SQUARE);
line(65, 75, 175,75);
noStroke();
fill(0);
ellipse(90, 25, 80, 30);
fill(0);
ellipse(60, 55, 35, 70);
fill(0);
ellipse(165, 30, 50, 30);
fill(0);
ellipse(175, 65, 20, 70);
//mulut
fill(255, 255, 0);
rect(95, 85, 48, 25);
fill(255, 0, 0);
arc(95,95,30,25,0,1.57);
fill(255, 0, 0);
arc(110,95,30,25,0,1.57);
fill(255, 0, 0);
arc(125,95,30,25,0,1.57);

//DRAW MATA
//kiri
noStroke();
fill (255);
ellipse(100,65,25,25);

//kanan
noStroke();
fill (255);
ellipse(140,65,25,25);

//tangan
//kiri
noStroke();
fill (255, 170, 130);
rect(30, 115, 25,85);
noStroke();
fill (255, 0, 0);
ellipse(43, 120, 26,45);
noStroke();
fill (0);
rect(35, 185, 4,15);
noStroke();
fill (0);
rect(45, 185, 4,15);
//kanan
noStroke();
fill (255, 170, 130);
rect(185, 115, 25,85);
noStroke();
noStroke();
fill (255, 0, 0);
ellipse(198, 120, 26,45);
noStroke();
fill (0);
rect(190, 185, 4,15);
noStroke();
fill (0);
rect(200, 185, 4,15);

//badan
noStroke();
fill (0,0,255);
rect(65, 125, 110,95);

//kaki
//kiri
noStroke();
fill (255, 170, 130);
rect(85, 225, 25,95);
noStroke();
fill (0);
ellipse(85,325,40,25);
noStroke();
fill (0);
rect(100, 318, 10,25);
//kanan
noStroke();
fill (255, 170, 130);
rect(125, 225, 25,95);
noStroke();
fill (0);
ellipse(150,325,40,25);
noStroke();
fill (0);
rect(125, 318, 10,25);

//rok
fill(255, 255, 0);
rect(65, 200, 110, 10);
fill(255, 255, 0);
rect(65, 180, 110, 10);
noStroke();
fill (255, 0, 0);
ellipse(120,190,25,25);
fill(0);
arc(65,215,220,150,0,1.57);

// hiasan
stroke(255,0,0);
arc(110,235,10,5,0,7);
stroke(255,0,0);
arc(155,35,10,5,00,1);
noStroke();
fill(255, 255, 0);
ellipse(157,35,10,10);
fill(0);
arc(95,155,40,50,0,4.5);

//draw ellipse
noStroke();
fill(255, 95, 17);
ellipse(300,200,100,100);
ellipse(400,200,100,100);
ellipse(350,288,100,100);

Berikut hasilnya :

## semoga bermanfaat ##