Animasi Coding

Minigui extended dapat juga untuk membuat program animasi seperti TOM & JERY .

Screen Shoot

This is Coding

#include “minigui.ch”

#define c1Tab CHR(9)
#define NTrim( n ) LTRIM( STR( n, IF( n == INT( n ), 0, 2 ) ) )

Memvar aPictures, aImageInfo
Memvar TotalFrames, CurrentFrame

Function main()
Local picture
Local aPictInfo := {}
Public aPictures := {}, aImageInfo := {}
Public TotalFrames, CurrentFrame

picture := Getfile ( { {‘Gif Files’, ‘*.gif’} }, ‘Open a File’ , GetCurrentFolder(), .f. , .t. )

IF Empty( picture )
picture := ‘ani-free.gif’
LoadGif( picture, @aPictInfo, @aPictures, @aImageInfo )
ELSE
IF !LoadGif( picture, @aPictInfo, @aPictures, @aImageInfo )
QUIT
ENDIF
ENDIF

TotalFrames := Len( aPictures )
CurrentFrame := 1

DEFINE WINDOW Form_Main ;
AT 0,0 ;
WIDTH 520 HEIGHT 440 ;
TITLE ‘Gif89 Demo’ ;
MAIN ;
ON INTERACTIVECLOSE OnClose()

DEFINE MAIN MENU

DEFINE POPUP “&File”

MENUITEM ‘&Play’ ACTION IIF( TotalFrames > 1, Form_Main.Timer_1.Enabled := .T., )
MENUITEM ‘&Stop’ ACTION IIF( TotalFrames > 1, Form_Main.Timer_1.Enabled := .F., )
SEPARATOR
MENUITEM “E&xit” ACTION OnClose()

END POPUP

DEFINE POPUP “&?”

MENUITEM “GIF &Info” ACTION IIF( TotalFrames > 1, ;
( Form_Main.Timer_1.Enabled := .F., MsgMulty( { ;
“Picture name” + c1Tab + “: ” + cFileNoPath( picture ), ;
“Gif Version” + c1Tab + “: ” + aPictInfo [1], ;
“Image Width” + c1Tab + “: ” + NTrim( aPictInfo [2] ), ;
“Image Height” + c1Tab + “: ” + NTrim( aPictInfo [3] ), ;
“Total Frames” + c1Tab + “: ” + NTrim( TotalFrames ), ;
“CurrentFrame” + c1Tab + “: ” + NTrim( CurrentFrame ) }, ;
“GIF Info” ), Form_Main.Timer_1.Enabled := .T. ), )

END POPUP

END MENU

@ 20, 20 IMAGE Image_1 PICTURE picture ;
WIDTH aPictInfo [2] ;
HEIGHT aPictInfo [3] ;
STRETCH

END WINDOW

IF TotalFrames > 1

DEFINE TIMER Timer_1 OF Form_Main INTERVAL GetFrameDelay( aImageInfo [CurrentFrame] ) ;
ACTION PlayGif()

Form_Main.Image_1.Picture := aPictures [CurrentFrame]
Form_Main.Timer_1.Enabled := .T.
Form_Main.Width := Max( 180, aPictInfo [2] + 2 * GetBorderWidth() + 40 )
Form_Main.Height := GetTitleHeight() + aPictInfo [3] + 2 * GetBorderHeight() + 60
Form_Main.Image_1.Col := ( Form_Main.Width – aPictInfo [2] – 2 * GetBorderWidth() ) / 2 + 1

DRAW PANEL IN WINDOW Form_Main ;
AT Form_Main.Image_1.Row – 2, Form_Main.Image_1.Col – 2 ;
TO Form_Main.Image_1.Row + aPictInfo [3], Form_Main.Image_1.Col + aPictInfo [2]
ENDIF

CENTER WINDOW Form_Main

ACTIVATE WINDOW Form_Main

Return Nil

/*
*/
Function PlayGif()

IF CurrentFrame 1
Form_Main.Timer_1.Release
ENDIF

Form_Main.Release

Return Nil

/*
*/
#include “h_Gif89.prg”
#include “MsM.prg”

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: