Love What You Do, Do What You Love

Contoh Membuat Gambar menggunakan Delphi 7

Posted by : Unknown
Minggu, 30 Desember 2012

ketika di tekan button di atas maka akan berubah menjadi seperti ini:


Bagaimanakah caranya? Hanya menambahkan Pseudo Code di bawah ini ke dalam button:

begin
  label1.Caption:='Fuji Mountain with Shinkanshen';
  with image2.Canvas do
  begin
    //langit
    brush.color:=clhighlight;
    pen.Color:=clhighlight;
    rectangle(0,0,401,200);

    //matahari
    brush.color:=clyellow;
    ellipse(10,10,80,80);

    //gunung
    brush.Color:=clhotlight;
 polygon([point(0,200),point(170,50),point(230,50),point(401,200),point(290,205),point(300,195),point(190,205),point(200,195),point(90,205),point(100,195)]);

    //puncak gunung
    brush.Color:=clwindow;
 polygon([point(230,50),point(170,50),point(135,80),point(175,65),point(185,95),point(200,70),point(220,90),point(230,65),point(265,80)]);

    //sakura
    brush.Color:=clfuchsia;
    pen.Color:=clfuchsia;
 polygon([point(0,200),point(100,195),point(90,205),point(200,195),point(190,205),point(300,195),point(290,205),point(400,200),point(400,225),point(0,225)]);
    pen.Color:=clblack;
    pen.Width:=2;
    ellipse(-10,200,15,225);
    ellipse(5,200,30,225);
    ellipse(20,200,45,225);
    ellipse(35,200,60,225);
    ellipse(50,200,75,225);
    ellipse(65,200,90,225);
    ellipse(80,200,105,225);
    ellipse(95,200,120,225);
    ellipse(110,200,135,225);
    ellipse(125,200,150,225);
    ellipse(140,200,165,225);
    ellipse(155,200,180,225);
    ellipse(170,200,195,225);
    ellipse(185,200,210,225);
    ellipse(200,200,225,225);
    ellipse(215,200,240,225);
    ellipse(230,200,255,225);
    ellipse(245,200,270,225);
    ellipse(260,200,285,225);
    ellipse(275,200,300,225);
    ellipse(290,200,315,225);
    ellipse(305,200,330,225);
    ellipse(320,200,345,225);
    ellipse(335,200,360,225);
    ellipse(350,200,375,225);
    ellipse(365,200,390,225);
    ellipse(380,200,405,225);

    //rumput
    brush.color:=cllime;
    pen.Color:=cllime;
    rectangle(0,225,401,350);

    //batang pohon
    brush.color:=clolive;
    pen.Color:=clolive;
    rectangle(0,225,5,250);
    rectangle(15,225,20,250);
    rectangle(30,225,35,250);
    rectangle(45,225,50,250);
    rectangle(60,225,65,250);
    rectangle(75,225,80,250);
    rectangle(90,225,95,250);
    rectangle(105,225,110,250);
    rectangle(120,225,125,250);
    rectangle(135,225,140,250);
    rectangle(150,225,155,250);
    rectangle(165,225,170,250);
    rectangle(180,225,185,250);
    rectangle(195,225,200,250);
    rectangle(210,225,215,250);
    rectangle(225,225,230,250);
    rectangle(240,225,245,250);
    rectangle(255,225,260,250);
    rectangle(270,225,275,250);
    rectangle(285,225,290,250);
    rectangle(300,225,305,250);
    rectangle(315,225,320,250);
    rectangle(330,225,335,250);
    rectangle(345,225,350,250);
    rectangle(360,225,365,250);
    rectangle(375,225,380,250);
    rectangle(390,225,395,250);

    //semak-semak
    brush.color:=clgreen;
    pen.Color:=clgreen;
    pen.Width:=1;
    rectangle(310,350,405,395);
    ellipse(280,320,340,390);
    ellipse(300,300,360,390);
    ellipse(340,320,400,390);

    //buah di semak-semak
    brush.Color:=clyellow;
    pen.Color:=clyellow;
    ellipse(340,340,345,345);
    ellipse(320,320,325,325);
    ellipse(370,370,375,375);
    ellipse(340,360,345,365);
    ellipse(360,350,365,355);
    ellipse(315,345,320,350);
    ellipse(380,335,385,340);

    //batu di rel
    brush.Color:=clgray;
    pen.Color:=clgray;
    pen.Width:=1;
    rectangle(0,385,405,465);

    //rel
    brush.Color:=clmaroon;
    pen.Color:=clblack;
    pen.Width:=1;
    polygon([point(0,455),point(20,455),point(70,395),point(90,395)]);
    polygon([point(60,455),point(80,455),point(130,395),point(110,395)]);
    polygon([point(120,455),point(140,455),point(190,395),point(170,395)]);
    polygon([point(180,455),point(200,455),point(250,395),point(230,395)]);
    polygon([point(240,455),point(260,455),point(310,395),point(290,395)]);
    polygon([point(300,455),point(320,455),point(370,395),point(350,395)]);
    polygon([point(360,455),point(380,455),point(430,395),point(410,395)]);
    rectangle(0,445,405,455);
    rectangle(0,385,405,395);

    //ban
    pen.Width:=1;
    brush.color:=clblack;
    pen.Color:=clblack;
    ellipse(180,405,220,445);
    ellipse(140,405,180,445);
    ellipse(100,405,140,445);

    ellipse(20,405,60,445);
    ellipse(-20,405,20,445);

    brush.Color:=clsilver;
    pen.color:=clblack;
    rectangle(120,430,200,435);
    rectangle(0,430,40,435);

    //shinkansen
    begin
    brush.Color:=clsilver;
    pen.Color:=clblack;
    pen.Width:=3;
    polygon([point(0,275),point(270,275),point(200,325),point(0,325)]);
    polygon([point(200,325),point(270,275),point(320,370),point(250,425)]);
    polygon([point(0,325),point(200,325),point(250,423),point(0,423)]);
    polygon([point(250,425),point(320,370),point(320,385),point(250,440)]);
    end;

    //garis merah di shinkansen
    pen.Width:=1;
    brush.color:=clred;
    pen.color:=clblack;
    polygon([point(0,390),point(0,400),point(240,400),point(235,390)]);
    polygon([point(235,390),point(240,400),point(310,350),point(305,340)]);

    //kaca
    pen.Width:=1;
    brush.Color:=claqua;
    polygon([point(215,335),point(270,295),point(290,330),point(235,371)]);
    polygon([point(190,330),point(205,385),point(100,385),point(100,330)]);
    rectangle(0,330,90,385);

    //garis di atas shinkanshen
    moveto(0,285); lineto(240,285);
    moveto(0,300); lineto(180,300);
    moveto(0,315); lineto(200,315);

    //frame
    pen.Color:=clwhite;
    pen.Width:=15;
    moveto(0,0);
    lineto(401,0);
    moveto(401,0);
    lineto(401,465);
    moveto(401,465);
    lineto(0,465);
    moveto(0,465);
    lineto(0,0);
    end;
end;



4 comments:

Unknown mengatakan...

Wah keren, gambarnya pake koding :D
Ngeliat gambarnya jadi inget kelas SD, kelas SD saya cuma bisa gambar gitu, gunung dan matahari :D
Jadi pengen bisa gambar pake koding juga :D

Unknown mengatakan...

sebenernya gampang kok,, cuman bermain dengan bidang2 geometri aja yang disusun rapi :D
kebetulan waktu ada tugas bikin gambar di delphi saya kepikirannya gambar yang sederhana saja,, :D
silahkan dicoba, saya yakin pasti bisa membuat gambar yang lebih bagus daripada saya :)

Unknown mengatakan...

trus kesimpulan program ini apa?
trus bisa gk menampilkan gambar yang awal?

Unknown mengatakan...

Assalamu'alaikum..
sebelumnya salam kenal.

begini, kak..
dari pertemuan pertama ana ikut mata kuliah komputer grafik, udah nggak nyambung. bingung ajha.. mau menempatkan ukuran x dan y-nya itu gimana..

kug ana melihat di blog kakak, rasanya gampang banget. sebenarnya pembelajarannya gimana, sih..kak? mohon bantuannya.. ^_^

Copyright © 2012 Zuka Zuka World | Hatsune Miku Theme | Designed by Johanes DJ