Membuat Lingkaran Dengan MidPoint Circle Algorithm di Processing

Processing merupakan bahasa pemrograman dan lingkungan pemrograman (development environment) open source untuk memprogram gambar, animasi dan interaksi.

Program ini berbasis Java, sehingga untuk menjalankannya dibutuhkan instalasi JDK dan JRE terlebih dahulu.

Di bawah ini akan saya contohkan bagaimana membuat lingkaran di Processing menggunakan MidPoint Circle Algorithm.

void midDrawCircle(int x1,int y1,int r)
{
 int x=0,y=r,p=1-r;
 int xctr=x1,yctr=y1;
   stdPoint(xctr+x,yctr+y);
   stdPoint(xctr-x,yctr+y);
   stdPoint(xctr+x,yctr-y);
   stdPoint(xctr-x,yctr-y);
   stdPoint(xctr+y,yctr+x);
   stdPoint(xctr-y,yctr+x);
   stdPoint(xctr+y,yctr-x);
   stdPoint(xctr-y,yctr-x);
 while(x<y)
 {
 x++;
 if(p<0)
  p+=2*x+1;
  else
  {
   y--;
   p+=2*(x-y)+1;
  }
   stdPoint(xctr+x,yctr+y);
   stdPoint(xctr-x,yctr+y);
   stdPoint(xctr+x,yctr-y);
   stdPoint(xctr-x,yctr-y);
   stdPoint(xctr+y,yctr+x);
   stdPoint(xctr-y,yctr+x);
   stdPoint(xctr+y,yctr-x);
   stdPoint(xctr-y,yctr-x);
 }
}

untuk menjalankannya, tinggal memanggil method midDrawCircle() di void draw().

Selamat mencoba :mrgreen:

ITB Programming Contest 2011

Setelah sukses dalam mengadakan ITB PROGRAMMING CONTEST 2010, Institut Teknologi Bandung kembali mengadakan acara ITB PROGRAMMING CONTEST 2011. Acara ini diselenggarakan dengan mengangkat tema besar “New Wave in Programming Competition”. Tema ini diangkat dilandaskan pada keinginan untuk menghadirkan suatu kompetisi pemrograman dengan suatu standar baru yang lebih tinggi, sebagai salah satu cara untuk meningkatkan level kompetisi pemrograman di Indonesia, sehingga dapat memperkuat wakil Indonesia di ajang kompetisi Internasional. Continue reading

ASCII Pronunciation Rules for Programmers

Sebagai programmer, kita pasti berurusan dengan banyak karakter ascii keyboard yang tidak biasa, yang jarang diketikkan, seperti:

$ # % {} * [] ~ & <>

Karakter² itu punya arti yg berbeda.

Lalu bagaimana cara pengucapannya?

Berapa banyak dari pengucapan ASCII yang Anda kenali? Mana yang “benar”? Atau jangan² selama ini masih ada yg salah dalam pengucapannya.

Berikut ini list dari karakter ASCII yg sering digunakan dan cara pengucapannya. Continue reading

Notable Programming Quotes

  • Walking on water and developing software from a specification are easy if both are frozen.
  • Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
  • Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
  • The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
  • Linux is only free if your time has no value.
  • It works on my machine.
  • It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter.
  • If debugging is the process of removing software bugs, then programming must be the process of putting them in.
  • A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila.
  • The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.
  • Measuring programming progress by lines of code is like measuring aircraft building progress by weight.
  • There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.
  • With regard to adding more programmers to get a project done faster…Nine people can’t make a baby in a month.
  • A programmer started to cuss
  • Because getting to sleep was a fuss
  • As he lay there in bed
  • Looping ’round in his head
  • was: while(!asleep()) sheep++;
  • Weeks of coding can save you hours of planning.
  • You can stand on the shoulders of giants OR a big enough pile of dwarfs, works either way.
  • Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
  • An idiot with a computer is a faster, better idiot
  • We better hurry up and start coding, there are going to be a lot of bugs to fix.
  • A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match.
  • Mostly, when you see programmers, they aren’t doing anything. One of the attractive things about programmers is that you cannot tell whether or not they are working simply by looking at them. Very often they’re sitting there seemingly drinking coffee and gossiping, or just staring into space. What the programmer is trying to do is get a handle on all the individual and unrelated ideas that are scampering around in his head.
  • I love deadlines. I like the whooshing sound they make as they fly by.
  • Never trust a programmer with a screw driver.

Getting Started with Android!

Dalam postingan kali ini saya akan memberikan tutorial instalasi Android SDK di Eclipse, cukup mudah ternyata :).

Instalasi

  1. Pastikan anda sudah menginstall Eclipse.
  2. Download Android SDK di sini.
  3. Gunakan Eclipse Update Manager untuk menginstall plugins yang tersedia untuk Android Development Tools (ADT) dari link https://dl-ssl.google.com/android/eclipse/
  4. Di Eclipse, buka Window – Preferences. Pilih Android dan path instalasi sesuai letak folder dari SDK yang tadi di download. Continue reading

Bash Scripting…

bash scripting, sebenarnya hanyalah suatu batch programming, dimana user/sistem hanya menyusun dan menjalankan tools yang telah tersedia dengan menggunakan dasar pemrograman standar di dalam suatu file teks yang executable. fungsi if, case, while dsb (fungsi standar bahasa pemrograman) ada disini.

syntax dasar penulisan bahasa pemrograman ini : semua file bash script harus diawali dengan :
#!/bin/bash

Continue reading