|
Grafik dan Animasi |
| for fs01.05 |
| back |
| 3.2 Contoh Animasi |
| Grafik dan Animasi -> Kreasi Animasi Grafik -> Contoh Animasi |
|
Pada
bagian ini disajikan beberapa contoh aplikasi animasi gambar, yang
dilakukan berdasarkan cara menyimpan memori dan atau gabungan dengan cara
hapus gambar. Contoh
Program 3.2.1 Program tulisan_bergerak; Uses Crt, graph; Var Xmax,ymax, gd, gm, i, x, y : integer; ArcCoords : ArcCoordsType; Geser1, geser2, kedip : Pointer; Size1, size2, size3 : word Begin Gd : CGA; Gm := CGAHi; InitGraph(gd,gm,’’); If GraphResult <> Grok
then halt(1); Xmax : GetMaxX; Ymax := GetMaxY; X := xmax div 10; Y := ymax div 10; Rectangle(0,0, xmax,ymax); MoveTo(x,5*y); SetTextStyle(TriplexFont,HorizDir,2); SetTextJustify(CenterText,CenterText); OutText(‘Animasi’); Size1 := ImageSize(x-42,5*y-5,
x+42,5*y+9); GetMem(geser1,size1); GetImage(x-42,5*y-5,
x+42,5*y+9,geser1^); MoveTo(8*x,5*y); SetTextStyle(Triplexfont,HorizDir,2); SetTextJustify(CenterText,CenterText); OutText(‘Grafik’); Size2 := ImageSize(8*x-35,5*y-5,
8*x+42,5*y+9); GetMem(geser2,size2); GetImage(8*x-35,5*y-5,
8*x+42,5*y+9,geser2^); For i := 0 to 3*x-10 do Begin Sound(10*i); PutImage(x-42+i,5*y-5,
geser1^,NormalPut); PutImage(8*x-35-i,5*y-5,
geser2^,NormalPut); NoSound; End; Size3 := ImageSize(38x,5*y-5,
6*x,5*y+9); GetMem(kedip,size3); GetImage(3*x,5*y-5,
6*x,5*y+9,kedip^); Repeat SetViewPort(1,1,xmax-1, ymax-1,
ClipOn); PutImage(3*x,5*y-6,
kedip^,NormalPut); Delay(500); ClearViewPort; Delay(500); Until KeyPressed; CloseGraph; End. Contoh
Program 3.2.2 Program rutherford; Uses Crt, graph; Var Xmax, ymax, s, gd, gm, i, x, y : integer; ArcCoords : ArcCoordsType; putar : Pointer; Size : word Begin Gd : CGA; Gm := CGAHi; InitGraph(gd,gm,’’); If GraphResult <> Grok
then halt(1); Xmax : GetMaxX; Ymax := GetMaxY; X := xmax div 2; Y := ymax div 2; Rectangle(0,0, xmax,ymax); MoveTo(x,9*ymax div 10); SetTextStyle(0,HorizDir,1); SetTextJustify(CenterText,CenterText); OutText(‘Teori Rutherford
tentang Atom’); Circle(x-20,y, 90); PieSlice(x-20,y, 0,360, 20); SetColor(Black); OutTextXY(x-21,y,’+’); SetColor(GetMaxColor); X := 4*xmax div 10; Y := 8*ymax div 10; PieSlice(x,y, 0,360, 3); Size :=
ImageSize(x-4,y-2,x+4,y+2); GetMem(putar,size); GetImage(x-,y-2, x+4,y+2,
putar^); PutImage(x-4,y-2,
putar^,XorPut); For s := 0 to 300 do Begin Y :=
Round(50*cos(s*5.5*pi/200)); X :=
round(115*sin(s*5.5*pi/200)); PutImage(x+297,y+98,
putar^,XorPut); Delay(100); Sound(1500); PutImage(x+297,y+98,putar^,XorPut); NoSound; End; PutIMage(x+297,y+98,putar^,XorPut); Repeat until Keyressed; CloseGraph; |
|||
last change:
2005-01-22, Fendi Sudianto
n_fendi_s@yahoo.com