Showing posts with label processing. Show all posts
Showing posts with label processing. Show all posts
9

TUTORIAL PROCESSING -GAMBAR LEBAH DAN BUNGA PROCESSING

Wednesday, June 7, 2017


Hai Teman  Teman LK pada kesempatan yang berbahagia ini admin akan memberikan sebuah gambar dari sebuah aplikasi yaitu aplikasi processing. kalo kita pikir pikir ngapain sih pakai processing, kenapa gak pakai Paint atau Corel draw atau yang lebih keren lagi Photoshop. kalo menurut admin ni processing ini lah campuran dari seni  , (menurut admin yaa). karena di dalam Processing ini kita belajar koordinat belajar warna html , bentuk bentuk yang semuanya itu tidak semudah membalikkan telapak tangan , semua harus dikerjakan secara teliti dan harus memiliki koordinat yang pas. bayangkan jika kita memakai Paint misalnya . pasti akan mudah membuat lingkaran , sedangkan di processing membutuhkan koordinat yang pas supaya menjadi lingkaran.jadi itulah menurut Admin. sedikit cerita aja hihihi.

baiklah tanpa memperpanjang kata kata admin yang sebenarnya gak balakan dibaca juga , langsung aja di copy paste

berikut  source codenya
ingat ini menggunakan Processing

void setup()
{
  size(500,500);
  background(#50FF0D);
  smooth();
  fill(#EAD802);
  rect(250,280,10,90);
  fill(#009B8C);
  pushMatrix();
  translate(250,250);
  rotate(radians(9));
  fill(#FF0AC6);
  ellipse(20,0,90,40);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(60));
  fill(#FF0AC6);
  ellipse(20,0,90,40);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(111));
  fill(#FF0AC6);
  ellipse(20,0,90,40);
  popMatrix();

 pushMatrix();
  translate(250,250);
  rotate(radians(162));
  fill(#FF0AC6);
  ellipse(20,0,90,40);
  popMatrix();
 
  pushMatrix(); translate(250,250);
  rotate(radians(253));
  fill(#FF0AC6);
  ellipse(20,0,90,40);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(303));
  fill(#FF0AC6);
  ellipse(20,0,90,40);
  line(20,0,55,0);
  popMatrix();
  //kelopak dalam
  pushMatrix();
  translate(250,250);
  rotate(radians(30));
  fill(#FF0AC6);
  ellipse(20,0,60,40);
  line(20,0,40,0);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(90));
  fill(#FF0AC6);
  ellipse(20,0,60,40);
   line(20,0,40,0);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(130));
  fill(#FF0AC6);
  ellipse(20,0,60,40);
   line(20,0,40,0);
  popMatrix();
 
 pushMatrix();
  translate(250,250);
  rotate(radians(220));
  fill(#FF0AC6);
  ellipse(20,0,60,40);
   line(20,0,40,0);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(275));
  fill(#FF0AC6);
  ellipse(20,0,60,40);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(330));
  fill(#FF0AC6);
  ellipse(20,0,60,40);
   line(20,0,40,0);
  popMatrix();
 
  pushMatrix();
  translate(250,250);
  rotate(radians(330));
  fill(#EAD802);
  ellipse(0,80,80,30);
  popMatrix();
  //lingkaran
  fill(#EAD802);
  ellipse(250,250,50,50);
  //lebah
  //sayap
  pushMatrix();
  translate(250,250);
  rotate(radians(70));
  fill(#FFFCFE);
  ellipse(-70,40,70,30);
  popMatrix();
  pushMatrix();
  translate(250,250);
  rotate(radians(20));
  fill(#FFFCFE);
  ellipse(-70,-10,70,20);
  popMatrix();
  //antena
  pushMatrix();
  translate(200,200);
  rotate(radians(-3));
  strokeWeight(2);
  line(55,0,0,0);
  popMatrix();
  pushMatrix();
  translate(220,200);
  rotate(radians(290));
  strokeWeight(2);
  line(30,0,0,0);
  popMatrix();
 
  //badan
  pushMatrix();
  translate(250,250);
  rotate(radians(60));
  fill(#FFFCFE);
  ellipse(-30,30,60,30);
  popMatrix();
  pushMatrix();
  translate(250,250);
  rotate(radians(255));
  fill(#FFFCFE);
  ellipse(20,-60,40,20);
  popMatrix();
  //badan
  pushMatrix();
  translate(250,250);
  rotate(radians(330));
  fill(#EAD802);
  ellipse(-40,-55,60,45);
  popMatrix();
  pushMatrix();
  translate(250,250);
  rotate(radians(360));
  fill(#EAD802);
  ellipse(-40,-40,50,50);
  popMatrix();
  //mata
  pushMatrix();
  translate(250,250);
  rotate(radians(330));
  fill(0);
  ellipse(-15,-40,10,5);
  popMatrix();
  pushMatrix();
  translate(250,250);
  rotate(radians(330));
  fill(0);
  ellipse(-15,-67,10,5);
  popMatrix();
 
  //antena
 
  pushMatrix();
  translate(250,250);
  rotate(radians(320));
  fill(#EAD802);
  ellipse(40,-70,10,10);
  popMatrix();
  pushMatrix();
  translate(250,250);
  rotate(radians(320));
  fill(#EAD802);
  ellipse(40,-35,10,10);
  popMatrix();
 
  pushMatrix();
  translate(200,230);
  rotate(radians(330));
  fill(0);
  ellipse(5,-10,3,10);
  popMatrix();
   fill(0, 24, 133);
  textSize(30);
  text( "LkLabkodingan", width/2, 80);
 
}


Baiklah  sekian Share admin kali ini . kita tunggu saja apa yang terbaru dari admin. akhir kata saya ucapkan terimakasih .
12

TUTORIAL-Game Snake Shenia DI Processing

Sunday, June 4, 2017
Salam Sejahtra buat kita semua , Pertama tama marilah kita ucapkan Puji syukur atas kehadirat Tuhan Yang Maha Esa yang mana masih memberikan Rahmat dan limpahannya .
Pernah gak terpikir bagaimana sih membuat Game sederhana Yang di hp hp jadul hehehehe. Baiklah saya di sini akan memberikan Tutorial membuat Game Ular Snake Shenia langsung saja ya

Pertama tama Buka Aplikasi Processing

tinggal Copy Source Code di bawah ini dan masukkan di Processing.





snake test;
food food1;
int highScore;

void setup(){
  size(1000, 600);
  frameRate(14);
  test = new snake();
  food1 = new food();
  rectMode(CENTER);
  textAlign(CENTER, CENTER);
 
  highScore = 0;
}



void draw(){
  background(255, 255, 255);
  drawScoreboard();
 
  test.move();
  test.display();
  food1.display();
 
 
  if( dist(food1.xpos, food1.ypos, test.xpos.get(0), test.ypos.get(0)) < test.sidelen ){
    food1.reset();
    test.addLink();
  }
 
  if(test.len > highScore){
    highScore= test.len;
  }
}


void keyPressed(){
  if(key == CODED){
    if(keyCode == LEFT){
      test.dir = "left";
    }
    if(keyCode == RIGHT){
      test.dir = "right";
    }
    if(keyCode == UP){
      test.dir = "up";
    }
    if(keyCode == DOWN){
      test.dir = "down";
    }
  }
}


void drawScoreboard(){
  // All of the scode for code and title
 
  fill(0, 24, 133);
  textSize(65);
  text( "GAME ULAR", width/2, 80);
 
 
  // draw scoreboard
  stroke(179, 140, 198);
  fill(0,0,255);
  rect(90, 70, 160, 80);
  fill(255, 255, 255);
  textSize(17);
  text( "Score: " + test.len, 70, 50);
 
  fill(255,255,255);
  textSize(17);
  text( "High Score: " + highScore, 70, 70);
}

class food{
 
  // define varibles
  float xpos, ypos;
 
 
 
  //constructor
  food(){
    xpos = random(100, width - 100);
    ypos = random(100, height - 100);
  }
 
 
  // functions
 void display(){
  
   fill(11,0,83);
   ellipse(xpos, ypos,17,17);
 }


 void reset(){
    xpos = random(100, width - 100);
    ypos = random(100, height - 100);
 }  
}

class snake{
 
  //define varibles
  int len;
  float sidelen;
  String dir;
  ArrayList xpos, ypos;
 
  // constructor
  snake(){
    len = 1;
    sidelen = 17;
    dir = "right";
    xpos = new ArrayList();
    ypos = new ArrayList();
    xpos.add( random(width) );
    ypos.add( random(height) );
  }
 
  // functions
 
 
  void move(){
   for(int i = len - 1; i > 0; i = i -1 ){
    xpos.set(i, xpos.get(i - 1));
    ypos.set(i, ypos.get(i - 1)); 
   }
   if(dir == "left"){
     xpos.set(0, xpos.get(0) - sidelen);
   }
   if(dir == "right"){
     xpos.set(0, xpos.get(0) + sidelen);
   }
  
   if(dir == "up"){
     ypos.set(0, ypos.get(0) - sidelen);
 
   }
  
   if(dir == "down"){
     ypos.set(0, ypos.get(0) + sidelen);
   }
   xpos.set(0, (xpos.get(0) + width) % width);
   ypos.set(0, (ypos.get(0) + height) % height);
  
    // check if hit itself and if so cut off the tail
    if( checkHit() == true){
      len = 1;
      float xtemp = xpos.get(0);
      float ytemp = ypos.get(0);
      xpos.clear();
      ypos.clear();
      xpos.add(xtemp);
      ypos.add(ytemp);
    }
  }
 
 
 
  void display(){
    for(int i = 0; i
      stroke(179, 140, 198);
      fill(0, 111, 191, map(i-1, 0, len-1, 250, 50));
      rect(xpos.get(i), ypos.get(i), sidelen, sidelen);
    } 
  }
 
 
  void addLink(){
    xpos.add( xpos.get(len-1) + sidelen);
    ypos.add( ypos.get(len-1) + sidelen);
    len++;
  }
 
   boolean checkHit(){
    for(int i = 1; i < len; i++){
     if( dist(xpos.get(0), ypos.get(0), xpos.get(i), ypos.get(i)) < sidelen){
       return true;
     }
    }
    return false;
   }
}



 Ahkir kata saya ucapkan Terima Kasih

9

TUTORIAL-Membuat Pemandangan dan ada mobil bergerak with PROCESSING

Friday, June 2, 2017
Salam Sejahtera untuk kita semua, kembali saya akan membagi kan sebuah contoh membuat animasi sistem Tata surya mengunakan aplikasi “PROCESSING".

Tanpa Basa basi . Langsung saja kita copy Souce Code :)


float x, y, z;
float size = 75;
float M,K;
void setup()
{
  size(1000,550);
  frameRate(30);
}
void draw()
{
   int d;
  d=second();
     background(153,170,0+50*d,0);
     fill(#606421);
     rect(0,300,1000,250);
    
     //gunung
     fill(#14D815);
     triangle(550,300,1010,300,850,90);
      triangle(150,300,570,300,400,120);

 // jalan
 fill(0);
 quad(10,300,150,600,300,600,30,300);
 rect(0,450,1000,100);
  stroke(252,252,252);
 strokeWeight(2);
 line(245,630,170,520);
 line(160,510,120,450);
 line(115,440,75,380);
 line(70,370,21,300);
 line(0,500,70,500);
 line(200,500,270,500);
 line(290,500,360,500);
 line(380,500,450,500);
 line(470,500,540,500);
 line(560,500,630,500);
 line(650,500,720,500);
 line(740,500,810,500);
 line(830,500,900,500);
 line(920,500,990,500);

noStroke();
//matahari
fill(222+50*d,222,0);
ellipse(900,70,100,100);
//rumah
  fill(255,0,255);
triangle(155,350,125,375,185,375);
fill(20,100,200);
rect(125,375,60,30);
fill(0,100,0);
arc(120,405,30,50,(180*PI)/180,(0*PI)/180);
fill(0+50*d,250,250);
rect(140,375,15,10);
fill(#F0C330);
triangle(165,415,225,415,195,390);
fill(20,100,200);
rect(165,415,60,30);
fill(0,100,0);
arc(120,405,30,50,(180*PI)/180,(0*PI)/180);
fill(0+50*d,250,250);
rect(170,415,15,10);
fill(#F70A0A);
triangle(700,340,800,340,750,290);
fill(20,100,200);
rect(700,340,100,100);
fill(0,100,0);
arc(120,405,30,50,(180*PI)/180,(0*PI)/180);
fill(0+50*d,250,250);
rect(740,390,15,50);
rect(760,380,15,10);
noStroke();
fill(200,100,0);
triangle(120,320,90,340,150,340);
fill(200,0,0);
rect(100,340,40,20);
//pohon
fill(#369820);
triangle(850,350,890,350,870,320);
triangle(850,370,890,370,870,340);
triangle(850,390,890,390,870,360);
fill(#293E25);
rect(865,390,10,20);
fill(#369820);
triangle(800,350,840,350,820,320);
triangle(800,370,840,370,820,340);
triangle(800,390,840,390,820,360);
fill(#293E25);
rect(815,390,10,20);
fill(#369820);
triangle(600,350,640,350,620,320);
triangle(600,370,640,370,620,340);
triangle(600,390,640,390,620,360);
fill(#293E25);
rect(615,390,10,20);
fill(#369820);
triangle(550,350,590,350,570,320);
triangle(550,370,590,370,570,340);
triangle(550,390,590,390,570,360);
fill(#293E25);
rect(565,390,10,20);
fill(#369820);
triangle(500,350,540,350,520,320);
triangle(500,370,540,370,520,340);
triangle(500,390,540,390,520,360);
fill(#293E25);
rect(515,390,10,20);
//awan
    y = y + 0.8;
  translate(y-200, height/2-2*size/2);
fill(#E8EFF5);
ellipse(450,-50,70,45);
ellipse(500,-50,85,65);
ellipse(540,-50,70,35);
ellipse(700,-100,80,50);
ellipse(750,-100,95,75);
ellipse(780,-100,80,55);
ellipse(815,-100,75,40);
ellipse(250,-100,80,35);
ellipse(300,-100,80,45);
//mobil
fill(106,90,205);
rect(100,250,100,50);
fill(72,61,139);
rect(200,265,40,35);
fill(255);
rect(210,272,20,20);
fill(65);
ellipse(130,300,30,30);
ellipse(200,300,30,30);
}

Sekian Terima Kasih

8

TUTORIAL-Sistem Tata surya di Processing

Thursday, June 1, 2017

 Salam Sejahtera untuk kita semua, kali ini saya akan membagi kan sebuah contoh membuat animasi sistem Tata surya mengunakan aplikasi “PROCESSING".
Tanpa Basa basi . Langsung saja kita copy Souce Code :)

float theta = 0;
void setup() {
  size(1240, 724);
}

void draw() {
  background(0);
  stroke(0);

  // Translate to center of window to draw the sun.
  translate(width/2, height/2);
  fill(255, 200, 50);
  ellipse(0, 0, 100, 100);
  pushMatrix();
  rotate(theta);
  //merkurius
  translate(100, 0);
  fill(50, 200, 255);
  ellipse(-40,0 , 10, 10);
  // The earth rotates around the sun
 //venus
  translate(100, 0);
  fill(#E3CECE);
  ellipse(-140, -50, 20, 20);
  //bumi
  translate(100, 0);
  fill(50, 200, 255);
  ellipse(-270, -120, 30, 30);
  //mars
  translate(100, 0);
  fill(#DE6060);
  ellipse(-430,-160 , 25, 25);
  //yupiter
  translate(100, 0);
  fill(#DBCA2A);
  ellipse(-300, 100, 70, 70);
  //saturnus
  translate(100, 0);
  fill(#988C1C);
  ellipse(-300, -100, 45, 45);
  //uranus
  translate(100, 0);
  fill(#0FF6FC);
  ellipse(-320, -10, 40,40 );
  //neptunus
  translate(100, 0);
  fill(#156EE8);
  ellipse(-360, 0, 35, 35);
  //pluto
  translate(100, 0);
  fill(#E8BE15);
  ellipse(-410, 0, 10, 10);
  popMatrix();

  theta += 0.01;
//garisedar
  noFill();
  stroke(#FFF303);
  ellipse(0,0,120,120);
  ellipse(0,0,155,155);
  ellipse(0,0,245,245);
  ellipse(0,0,325,325);
  ellipse(0,0,450,450);
  ellipse(0,0,635,635);
  ellipse(0,0,760,760);
  ellipse(0,0,880,880);
  ellipse(0,0,980,980);
 
 
}

akhir kata saya ucapkan TerimaKasih :)