Kamis, 14 Mei 2009

APLIKASI I GRAFIKA KOMPUTER

Grafika computer memainkan peranan penting dalam sistem multimedia. Yang dimaksud multimedia dalam konteks ini adalah program yang mampu menjalankan file-file dari berbagai bentuk, mulai dari format teks, sound, image, bahkan video. Untuk merancang multimedia, Borland C++ Builder telah menyediakan komponen khusus yaitu media player.

INTERFACE :


SOURCE CODE :

//---------------------------------------------------------------------------

#include

#pragma hdrstop

#include "Unit1.h"

#pragma resource "*.dfm"

TForm1 *Form1; //

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BTGantiClick(TObject *Sender)

{

if (OpenDialog1->Execute()) // SAAT BUTTON GANTI DI EKSEKUSI MAKA AKAN MUNCUL OPEN DIALOG.

MediaPlayer1->FileName=OpenDialog1->FileName;

MediaPlayer1->Open();

MediaPlayer1->Display=Panel1; //MEMBUKA MEDIA PLATYER 1 PADA PANEL

RB2->Enabled=True; // KARENA TRUE MAKA SAAT MEDIA PLAYER LOAD BISA DI KLIK

RB3->Enabled=True; // KARENA TRUE MAKA SAAT MEDIA PLAYER LOAD BISA DI KLIK

RB4->Enabled=True; // KARENA TRUE MAKA SAAT MEDIA PLAYER LOAD BISA DI KLIK

}

// BATAS SCRIPNYA JIKA DI EKSEKUSI MAKA AKA MEMANGGGIL BTGANTI.

//---------------------------------------------------------------------------

void __fastcall TForm1::RB2Click(TObject *Sender)

{

RB3->Enabled=False; //AGAR SAAT RB2 DIKLIK MAKA RB3 TIDAK BISA DI KLIK

RB4->Enabled=False;

MediaPlayer1->Stop();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

MediaPlayer1->Wait=True;

MediaPlayer1->Play(); //SAAT DI PLAY SEMUA BATTON MENGALAMI TRUE DAN FALSE

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Enabled=False;

RB3->Enabled=False;

RB4->Enabled=False;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::RB3Click(TObject *Sender)

{

RB2->Enabled=False;

RB4->Enabled=False;

MediaPlayer1->Stop();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Enabled=False;

RB3->Enabled=False;

RB4->Enabled=False;

}

// FILE PADA SAAT DI JALANKAN AKAN MENGULANG LANGKAHNYA SEBANYAK 3 KALI

//---------------------------------------------------------------------------

void __fastcall TForm1::RB4Click(TObject *Sender)

{

RB2->Enabled=False;

RB3->Enabled=False;

MediaPlayer1->Stop();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

MediaPlayer1->Wait=True;

MediaPlayer1->Play();

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Enabled=False;

RB3->Enabled=False;

RB4->Enabled=False;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::RBAVYClick(TObject *Sender)

{

OpenDialog1->FileName="";

OpenDialog1->Filter="Audio Video(*.avi)|*.avi";

if (OpenDialog1->Execute())

MediaPlayer1->Close();

BTGanti->Enabled=True;

MediaPlayer1->DeviceType=dtAVIVideo; // MediaPlayer1 MEMBACA dtAVIVideo YAITU EXTENSI .avi

MediaPlayer1->FileName=OpenDialog1->FileName;

MediaPlayer1->Open();

Panel2->Caption="Gambar Yang bagus"; // akan muncul tulisan "Gambar Yang bagus" pada panel2 jika kita membuka file.

MediaPlayer1->Display=Panel1;

Panel5->Caption=OpenDialog1->FileName;

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Checked=False;

RB3->Checked=False;

RB4->Checked=False;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::RBWAVClick(TObject *Sender)

{

OpenDialog1->FileName="";

OpenDialog1->Filter="WAV Audio Files (*.wav)|*.wav";

if (OpenDialog1->Execute())

MediaPlayer1->Close();

BTGanti->Enabled=True;

MediaPlayer1->DeviceType=dtWaveAudio;

MediaPlayer1->FileName=OpenDialog1->FileName;

MediaPlayer1->Open();

Panel2->Caption="Maaf tidak ada gambar";

MediaPlayer1->Display=Panel1;

Panel5->Caption=OpenDialog1->FileName;

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Checked=False;

RB3->Checked=False;

RB4->Checked=False;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::RBMIDIClick(TObject *Sender)

{

OpenDialog1->FileName="";

OpenDialog1->Filter="Midi Files(*.midi)|*.midi";

if (OpenDialog1->Execute())

MediaPlayer1->Close();

BTGanti->Enabled=True;

MediaPlayer1->DeviceType=dtSequencer;

MediaPlayer1->FileName=OpenDialog1->FileName;

MediaPlayer1->Open();

Panel2->Caption="Maaf tidak ada gambar";

MediaPlayer1->Display=Panel1;

Panel5->Caption=OpenDialog1->FileName;

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Checked=False;

RB3->Checked=False;

RB4->Checked=False;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::RBCDClick(TObject *Sender)

{

MediaPlayer1->Close();

BTGanti->Enabled=True;

MediaPlayer1->DeviceType=dtCDAudio;

MediaPlayer1->FileName=EmptyStr;

MediaPlayer1->Open();

Panel2->Caption="Maaf, Tidak ada gambar";

MediaPlayer1->Display=Panel1;

Panel5->Caption="CD Audio";

RB2->Enabled=True;

RB3->Enabled=True;

RB4->Enabled=True;

RB2->Checked=False;

RB3->Checked=False;

RB4->Checked=False;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BTcloseClick(TObject *Sender)

{

Close(); //UNTUK MEMBACA SCRIP CLOSE. SEHINGGA SAAT I KLIK PROGRAM SELESAI

}

//---------------------------------------------------------------------------

UNIT1.H

#include

#include

#include

#include

//---------------------------------------------------------------------------

class TForm1 : public TForm

{

__published: // IDE-managed Components

TPanel *Panel1;

TPanel *Panel6;

TPanel *Panel3;

TPanel *Panel4;

TPanel *Panel5;

TPanel *Panel2;

TButton *BTGanti;

TButton *BTclose;

TGroupBox *GroupBox1;

TGroupBox *GroupBox2;

TRadioButton *RB2;

TRadioButton *RB3;

TRadioButton *RB4;

TRadioButton *RBAVY;

TRadioButton *RBWAV;

TRadioButton *RBMIDI;

TRadioButton *RBCD;

TMediaPlayer *MediaPlayer1;

TOpenDialog *OpenDialog1;

void __fastcall BTGantiClick(TObject *Sender);

void __fastcall RB2Click(TObject *Sender);

void __fastcall RB3Click(TObject *Sender);

void __fastcall RB4Click(TObject *Sender);

void __fastcall RBAVYClick(TObject *Sender);

void __fastcall RBWAVClick(TObject *Sender);

void __fastcall RBMIDIClick(TObject *Sender);

void __fastcall RBCDClick(TObject *Sender);

void __fastcall BTcloseClick(TObject *Sender);

private: // User declarations

public: // User declarations

__fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif



OUTPUT :

Rabu, 13 Mei 2009

R E N D E R I N G

Rendering (pengecatan) adalah sebuah cara dalam grafika computer untuk membuat pemandangan nampak ‘nyata’ atau visualisasi objek 3D menjadi riil. Untuk rendering objek 3D, ada beberapa factor yang mempengaruhi, diantaranya factor cahaya, sifat/karakteristik bahan, posisi kamera dan lain-lain. Suatu citra yang mengalami proses rendering yang baik akan menghasilkan gambar hasil akhir. Sedangkan tanpa rendering tidak akan menghasilkan gambar.

LIGHTING

Lighting atau pencahayaan merupakan suatu metode yang dapat kita terapkan pada proses rendering untuk menjadikan sebuah objek menjadi terlihat berbeda.

Dalam proses rendering , lighting dipengaruhi oleh factor-faktor sebagai berikut :

  1. jarak objek dengan sumber cahaya,
  2. posisi objek,
  3. bentuk permukaan objek

MODEL BAYANGAN

Sebuah objek akan memberikan sifat yang berbeda pada saat dikenai cahaya. Ada yang memantulkan, membiaskan ataupun menyerap cahaya.

WARNA

Terdapat empat dasar pendekatan pada proses pewarnaan untuk mengisi area atau sering dikenal dengan istilah fill area,yaitu : metode scanline, metode boundary fill dan metode flood fill.



INTERFACE :


SOURCE CODE :

//---------------------------------------------------------------------------

#include // membaca file vcl untuk memulai pembuatan program pada Borland C++ Builder

#pragma hdrstop // library yang sudah disediakan oleh Borland C++ Builder

#include "Unit1.h" // membaca file Unit1.h

//---------------------------------------------------------------------------

#pragma package(smart_init) // library yang sudah disediakan oleh Borland C++ Builder

#pragma resource "*.dfm" // library yang sudah disediakan oleh Borland C++ Builder

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

// memanggil fungsi TForm1

//------------------------------------------------------- PROGRAM STARTS HERE

Graphics::TBitmap* pix = new Graphics::TBitmap();

//komponen bitmap pada Borland untuk membuat objek baru

RGBTRIPLE* t;

int cycle = 0; à deklarasi cycle yang bertipe integer

int step;

bool stop = false;

//---------------------------------------------------- RENDER BITMAP FUNCTION

void renderBMP(Graphics::TBitmap* picture)

{

Form1->Canvas->Draw(0, 0, pix);

}

// memanggil fungsi renderBMP yaitu untuk menggambar dgn komponen canvas di form 1

//--------------------------------------------------- ALTER BITMAP FUNCTION

void bmpAlter(Graphics::TBitmap* picture)

{

stop = false;

// JIKA STOP BELUM DITEKAN MAKA BUTTON4 YAITU CANPTION STOP TIDAK ADA. SEHINGGA SAAT DIRENDER JIKA STOP MASIH BERNILAI STOP MAKA WARNA MASIH DIBACA SECARA BERULANG-ULANG

Form1->Button4->Caption = "Stop";

while (!stop)

{

for (step = 0; step <>

{

if (stop) break;

for (int y = 0; y <>Height; y++)

{

t = (RGBTRIPLE*)picture->ScanLine[y]; // MENDETEKSI GARIS-GARIS PADA GAMBAR

for (int x = 0; x <>Width; x++)

{

t->rgbtRed++;

t->rgbtGreen--;

t->rgbtBlue++;

t++;

}

}

Form1->Canvas->Draw(0, 0, pix);

cycle++;

if (cycle > 255) cycle = cycle -256;

Form1->Edit1->Text = cycle;

Application->ProcessMessages();

}

}

}

//-----------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

if (OpenPictureDialog1->Execute() )

pix->LoadFromFile(OpenPictureDialog1->FileName);

} à memanggil OpenPictureDialog1

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

{

renderBMP(pix);

} à buuton 2 memanggil renderBMP

//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)

{

bmpAlter(pix);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)

{

stop = !stop;

if (stop) {

Button4->Caption = "Start";

}

else {

Button4->Caption = "Stop";

bmpAlter(pix);

}

Application->ProcessMessages();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Edit1Change(TObject *Sender)

{

cycle = 0;

Form1->Edit1->Text = cycle;

}

// memanggil fungsi Edit1Change untuk mengubah objek cycle pada Form1

//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)

{

delete pix;

}

//memanggil fungsi FormClose untuk menghapus pix atau melakukan TCloseAction &Action



OUTPUT :


TRANSFORMASI OBYEK TIGA DIMENSI

Transformasi objek 3D merupakan perluasan dan teknik. Sebagaimana dalam transformasi 2D, sembarang transformasi dapat disajikan ke dalam suatu matrik transformasi dan transformasi yang lebih rumit dapat dinyatakan oleh sebuah matrik transformasi yang merupakan gabungan dari matrik-matrik transformasi dasar yang ada.

ROTASI

Pemutaran objek 3D dilakukan dengan pemutaran pada suatu sumbu atau gabungan dengan pemutaran pada sumbu-sumbu lain.

SHEARING

Shearing pada sembarang sepasang sumbu dapat dilaksanakan pada sumbu ke tiga.

  1. Matrik transformasi untuk shearing :

1) Kamera Sintetik

2) Sistem Koordinat Pandang

3) Menentukan arah kamera





INTERFACE :


SOURCE CODE :

//---------------------------------------------------------------------------

#include

#include

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

struct Elemen { float x,y ;} ;

Elemen Objek[17];

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)

{

int i;

for (i=1;i<=16;i++){ Objek[i].y-=5;};

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)

{

int i;

for (i=1;i<=16;i++){ Objek[i].x-=5;};

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button5Click(TObject *Sender)

{

int i;

for (i=1;i<=16;i++){ Objek[i].x+=5;};

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)

{

int i;

for (i=1;i<=16;i++){ Objek[i].x+=5;};

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button7Click(TObject *Sender)

{

int i;

for (i=1;i<=16;i++)

{ Objek[i].y*=2;

Objek[i].x*=2;

};

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button8Click(TObject *Sender)

{

int i;

for (i=1;i<=16;i++)

{

Objek[i].y/=2;

Objek[i].x/=2;

};

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button9Click(TObject *Sender)

{

Elemen TempObjek[17];

int i; float Sdt;

for (i=1;i<=16;i++)

{

Objek[i].x=Objek[i].x-Image1->Width / 2;

Objek[i].y=Objek[i].y-Image1->Height / 2;

Sdt=10*M_PI/180;

TempObjek[i].x=(Objek[i].x*cos(Sdt)-Objek[i].y*sin(Sdt));

TempObjek[i].y=(Objek[i].x*sin(Sdt)+Objek[i].y*cos(Sdt));

Objek[i]=TempObjek[i];

Objek[i].x=Objek[i].x+Image1->Width / 2;

Objek[i].y=Objek[i].y+Image1->Height / 2;

}

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button10Click(TObject *Sender)

{

Elemen TempObjek[17];

int i,n,m; float Sdt;

for (i=1;i<=16;i++)

{

n = Objek[3].x;

m = Objek[3].y;

Objek[i].x=Objek[i].x-n;

Objek[i].y=Objek[i].y-m;

Sdt=10*M_PI/180;

TempObjek[i].x=(Objek[i].x*cos(Sdt)-Objek[i].y*sin(Sdt));

TempObjek[i].y=(Objek[i].x*sin(Sdt)+Objek[i].y*cos(Sdt));

Objek[i]=TempObjek[i];

Objek[i].x=Objek[i].x+n;

Objek[i].y=Objek[i].y+m;

}

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

FormActivate(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

{

Close();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormActivate(TObject *Sender)

{

Objek[1].x = 100; Objek[1].y = 50;

Objek[2].x = 50; Objek[2].y = 50;

Objek[3].x = 50; Objek[3].y = 100;

Objek[4].x = 100; Objek[4].y = 100;

Objek[5].x = 125; Objek[5].y = 125;

Objek[6].x = 75; Objek[6].y = 125;

Objek[7].x = 75; Objek[7].y = 175;

Objek[8].x = 125; Objek[8].y = 175;

Objek[9].x = 100; Objek[9].y = 100;

Objek[10].x = 125; Objek[10].y = 175;

Objek[11].x = 50; Objek[11].y = 100;

Objek[12].x = 75; Objek[12].y = 175;

Objek[13].x = 50; Objek[13].y = 50;

Objek[14].x = 75; Objek[14].y = 125;

Objek[15].x = 100; Objek[15].y = 50;

Objek[16].x = 125; Objek[16].y = 125;

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormShow(TObject *Sender)

{

int i;

Image1->Canvas->Rectangle(0,0,Image1->Width,Image1->Height);

Image1->Canvas->MoveTo(Objek[4].x,Objek[4].y);

for (i=1;i<=4;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[8].x,Objek[8].y);

for (i=5;i<=8;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[10].x,Objek[10].y);

for (i=9;i<=10;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[12].x,Objek[12].y);

for (i=11;i<=12;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[14].x,Objek[14].y);

for (i=13;i<=14;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[16].x,Objek[16].y);

for (i=15;i<=16;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

}

//---------------------------------------------------------------------------

UNIT1.H

//---------------------------------------------------------------------------

#ifndef Unit1H

#define Unit1H

//---------------------------------------------------------------------------

#include

#include

#include

#include

#include

//---------------------------------------------------------------------------

class TForm1 : public TForm

{

__published: // IDE-managed Components

TImage *Image1;

TGroupBox *GroupBox1;

TGroupBox *GroupBox2;

TGroupBox *GroupBox3;

TButton *Button1;

TButton *Button2;

TButton *Button3;

TButton *Button4;

TButton *Button5;

TButton *Button6;

TButton *Button7;

TButton *Button8;

TButton *Button9;

TButton *Button10;

void __fastcall Button3Click(TObject *Sender);

void __fastcall Button4Click(TObject *Sender);

void __fastcall Button5Click(TObject *Sender);

void __fastcall Button6Click(TObject *Sender);

void __fastcall Button7Click(TObject *Sender);

void __fastcall Button8Click(TObject *Sender);

void __fastcall Button9Click(TObject *Sender);

void __fastcall Button10Click(TObject *Sender);

void __fastcall Button1Click(TObject *Sender);

void __fastcall Button2Click(TObject *Sender);

void __fastcall FormActivate(TObject *Sender);

void __fastcall FormShow(TObject *Sender);

private: // User declarations

public: // User declarations

__fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif


OUTPUT :

Rabu, 06 Mei 2009

OBYEK TIGA DIMENSI

Secara konseptual, jaring polygon digunakan dalam grafika computer untuk menghasilkan objek 3D. Penciptaan objek 3D dengan computer dilakukan dengan memanipulasi jaring polygon baik dengan pemrograman dan juga pemahaman geometri 3D. Jaring polygon adalah permukaan yang dibuat dari kumpulan-kumpulan muka-muka polygon.

Jaring dapat digunakan untuk membuat ‘kulit’ dari suatu objek. Ada dua cara untuk membuat objek 3D dengan jaring polygon, yaitu :

    1. Metode daftar titik (vertex list method)
    2. Metode daftar muka (face list method)
Ada beberapa cara pendefinisian jaring. Sebagai contoh untuk membuat bentuk kubus dapat diwakili dengan membuat satu daftar yang berisi daftar masing-masing polygon dan lokasi titik.


interface:


Source code Program :


Unit1.cpp

//---------------------------------------------------------------------------

#include // membaca file vcl untuk memulai pembuatan program pada Borland C++ Builder

#pragma hdrstop // library yang sudah disediakan oleh Borland C++ Builder

#include "Unit1.h" // membaca file Unit1.h

#pragma resource "*.dfm" // library yang sudah disediakan oleh Borland C++ Builder

TForm1 *Form1;

struct Elemen { float x,y ;} ; // objek berbentuk struktur dengan variabel X dan Y yang bertipe float

Elemen Objek[17]; // deklarasi elemen

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

// memanggil fungsi TForm1

//---------------------------------------------------------------------------

void __fastcall TForm1::FormActivate(TObject *Sender)

// memanggil fungsi FormActivate untuk membuat objek dengan menentukan titik-titik objek pada koordinat x dan y

{

Objek[1].x = 100; Objek[1].y = 50;

Objek[2].x = 50; Objek[2].y = 50;

Objek[3].x = 50; Objek[3].y = 100;

Objek[4].x = 100; Objek[4].y = 100;

Objek[5].x = 125; Objek[5].y = 125;

Objek[6].x = 75; Objek[6].y = 125;

Objek[7].x = 75; Objek[7].y = 175;

Objek[8].x = 125; Objek[8].y = 175;

// Objek 1 sampai objek 8 merupakan penulisan posisi titik dalam pembuatan objek.

Objek[9].x = 100; Objek[9].y = 100;

Objek[10].x = 125; Objek[10].y = 175;

Objek[11].x = 50; Objek[11].y = 100;

Objek[12].x = 75; Objek[12].y = 175;

Objek[13].x = 50; Objek[13].y = 50;

Objek[14].x = 75; Objek[14].y = 125;

Objek[15].x = 100; Objek[15].y = 50;

Objek[16].x = 125; Objek[16].y = 125;

//Objek 9 sampai objek 16 merupakan penulisan posisi garis dalam pembuatan objek.

FormShow(Sender);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormShow(TObject *Sender)

{

int i;

Image1->Canvas->Rectangle(0,0,Image1->Width,Image1->Height);

Image1->Canvas->MoveTo(Objek[4].x,Objek[4].y);

for (i=1;i<=4;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[8].x,Objek[8].y);

for (i=5;i<=8;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[10].x,Objek[10].y);

for (i=9;i<=10;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[12].x,Objek[12].y);

for (i=11;i<=12;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[14].x,Objek[14].y);

for (i=13;i<=14;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

Image1->Canvas->MoveTo(Objek[16].x,Objek[16].y);

for (i=15;i<=16;i++){ Image1->Canvas->LineTo(Objek[i].x,Objek[i].y);};

}

//memanggil fungsi FormShow

//-------------------------------------------------------------------------------------



Unit.h

// File ini berisi event handler untuk mengatasi sebuah event dari komponen yang ditempatkan pada sebuah form.

//---------------------------------------------------------------------------

#ifndef Unit1H

#define Unit1H

//---------------------------------------------------------------------------

#include

#include

#include

#include

#include

#include

//---------------------------------------------------------------------------

class TForm1 : public TForm

{

__published: // IDE-managed Components

TImage *Image1;

void __fastcall FormActivate(TObject *Sender);

void __fastcall FormShow(TObject *Sender);

private: // User declarations

public: // User declarations

__fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif




OUTPUT :