Lukisan dengan Borland C++

dalam mata kuliah grafika komputer kita di tuntut untuk bisa merekayasa code program sehingga menjadi bentuk grafika atau gambar 2d atau 3d, nah berikut ini saya tampilkan code dari borland c++ yang beberapa hari lalu saya gunakan dalam tugas grafika komputer…

Judul Lukisanya adalah Pantai

sebelum menuliskan code berikut ini, double klik di bagian Object Inspector > tab Event > OnPaint

//clear outline
Canvas->Rectangle(5,5,605,455);
Canvas->Pen->Style=psClear;

//frame image
Canvas->Brush->Color=clBlack;
Canvas->Rectangle(10,10,600,450);

//image moon
Canvas->Brush->Color=clYellow;
Canvas->Ellipse(300,20,370,90);
Canvas->Brush->Color=clBlack;
Canvas->Ellipse(300,30,350,80);

//sky 1
Canvas->Brush->Color=clGray;
Canvas->Ellipse(330,70,430,120);
Canvas->Ellipse(360,50,450,100);
Canvas->Ellipse(370,90,450,130);
Canvas->Ellipse(340,70,500,120);
Canvas->Ellipse(430,50,490,100);
//sky 2
Canvas->Ellipse(130,70,230,120);
Canvas->Ellipse(160,50,250,100);
Canvas->Ellipse(170,90,250,130);
Canvas->Ellipse(140,70,300,120);
Canvas->Ellipse(230,50,290,100);
//sea
Canvas->Brush->Color=clBlue;
Canvas->Rectangle(10,250,600,450);

//flag 1
Canvas->Brush->Color=clRed;
TPoint flag1[3];
flag1[0]=Point(150,180);
flag1[1]=Point(190,220);
flag1[2]=Point(150,260);
Canvas->Polygon(flag1,2);
//ship 1
Canvas->Brush->Color=clBtnFace;
TPoint ship1[4];
ship1[0]=Point(100,240);
ship1[1]=Point(200,240);
ship1[2]=Point(180,260);
ship1[3]=Point(120,260);
Canvas->Polygon(ship1,3);

//flag 2
Canvas->Brush->Color=clRed;
TPoint flag2[3];
flag2[0]=Point(130,280);
flag2[1]=Point(170,320);
flag2[2]=Point(130,360);
Canvas->Polygon(flag2,2);
//ship 2
Canvas->Brush->Color=clBtnFace;
TPoint ship2[4];
ship2[0]=Point(80,340);
ship2[1]=Point(180,340);
ship2[2]=Point(160,360);
ship2[3]=Point(100,360);
Canvas->Polygon(ship2,3);

//flag 3
Canvas->Brush->Color=clRed;
TPoint flag3[3];
flag3[0]=Point(250,230);
flag3[1]=Point(290,270);
flag3[2]=Point(250,310);
Canvas->Polygon(flag3,2);
//ship 3
Canvas->Brush->Color=clBtnFace;
TPoint ship3[4];
ship3[0]=Point(200,290);
ship3[1]=Point(300,290);
ship3[2]=Point(280,310);
ship3[3]=Point(220,310);
Canvas->Polygon(ship3,3);

//flag 4
Canvas->Brush->Color=clRed;
TPoint flag4[3];
flag4[0]=Point(350,330);
flag4[1]=Point(390,370);
flag4[2]=Point(350,410);
Canvas->Polygon(flag4,2);
//ship 4
Canvas->Brush->Color=clBtnFace;
TPoint ship4[4];
ship4[0]=Point(300,390);
ship4[1]=Point(400,390);
ship4[2]=Point(380,410);
ship4[3]=Point(320,410);
Canvas->Polygon(ship4,3);

//land
Canvas->Brush->Color=clCream;
TPoint titik[4];
titik[0]=Point(600,250);
titik[1]=Point(550,250);
titik[2]=Point(400,450);
titik[3]=Point(600,450);
Canvas->Polygon(titik,3);

//star 1
Canvas->Brush->Color=clWhite;
TPoint star1[5];
star1[0]=Point(80,110);
star1[1]=Point(75,120);
star1[2]=Point(85,115);
star1[3]=Point(75,115);
star1[4]=Point(85,120);
Canvas->Polygon(star1,4);
//star 2
Canvas->Brush->Color=clWhite;
TPoint star2[5];
star2[0]=Point(50,140);
star2[1]=Point(45,150);
star2[2]=Point(55,145);
star2[3]=Point(45,145);
star2[4]=Point(55,150);
Canvas->Polygon(star2,4);
//star 3
Canvas->Brush->Color=clWhite;
TPoint star3[5];
star3[0]=Point(120,130);
star3[1]=Point(115,140);
star3[2]=Point(125,135);
star3[3]=Point(115,135);
star3[4]=Point(125,140);
Canvas->Polygon(star3,4);
//star 4
Canvas->Brush->Color=clWhite;
TPoint star4[5];
star4[0]=Point(500,110);
star4[1]=Point(495,120);
star4[2]=Point(505,115);
star4[3]=Point(495,115);
star4[4]=Point(505,120);
Canvas->Polygon(star4,4);
//star 5
Canvas->Brush->Color=clWhite;
TPoint star5[5];
star5[0]=Point(470,140);
star5[1]=Point(465,150);
star5[2]=Point(475,145);
star5[3]=Point(465,145);
star5[4]=Point(475,150);
Canvas->Polygon(star5,4);
//star 6
Canvas->Brush->Color=clWhite;
TPoint star6[5];
star6[0]=Point(550,130);
star6[1]=Point(545,140);
star6[2]=Point(555,135);
star6[3]=Point(545,135);
star6[4]=Point(555,140);
Canvas->Polygon(star6,4);

nah setelah di run maka hasilnya seperti ini

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s