Jump to content
Tuts 4 You

X-88's Blog

Sign in to follow this  
  • entries
    2
  • comments
    10
  • views
    30,588

A simple way to make animations with Delphi.

Sign in to follow this  
X-88

12,136 views

blog-0894582001365629857.pngI've made ​​more simple, I include source manually code with different code as well,

Example + Source Code.

This time I just use my 4-layer stacking horizontally so easy to understand,

[120x80] [120x80] [120x80] [120x80] = [480 x 80]

may can help.

Download Source Code + Example ----------> ZNP Easy.zip

unit Unit1;

interface

uses

SysUtils, Graphics, Controls, Forms,

ExtCtrls, StdCtrls, ComCtrls, Classes;

type

TForm1 = class(TForm)

Memo1: TMemo;

Timer1: TTimer;

Label1: TLabel;

Image1: TImage;

Image2: TImage;

Image3: TImage;

Button1: TButton;

Button2: TButton;

Button3: TButton;

Button4: TButton;

GroupBox1: TGroupBox;

GroupBox2: TGroupBox;

GroupBox3: TGroupBox;

Timer2: TTimer;

Timer3: TTimer;

procedure Timer1Timer(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Timer2Timer(Sender: TObject);

procedure Timer3Timer(Sender: TObject);

private

{ X-88/Zephio }

public

{ April, 2013 }

{ Tools : Delphi 7, Adobe PS 7 & Resource Editor }

end;

var

Form1: TForm1;

IV, OnOff, LeftPosition, RightPosition : Integer;

implementation

{$R *.dfm}

{$R MR.res}

procedure SetComponentBorder(C : TControl; Colorr: Integer);

begin

with TShape.Create© do

begin

Parent := C.Parent;

Top := C.Top - 1;

Left := C.Left - 1;

Pen.Color := Colorr;

Width := C.Width + 2;

Height := C.Height + 2;

SendToBack;

end;

if C is TComboBox then

with TComboBox© do

begin

BevelInner := BVLowered;

BevelKind := BKFlat;

BevelOuter := BVNone;

end;

end;

procedure TForm1.FormCreate(Sender: TObject);

var

BM : TBitmap;

begin

DoubleBuffered := true;

BM := TBitmap.Create;

BM.LoadFromResourceName(HInstance,'Test');

Image1.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(0, 0, 120, 80));

//--------------------->

Image2.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(0, 0, 120, 80));

BM.Free;

//------------------------------------------>

IV := 1;

OnOff := 0;

LeftPosition := 0;

RightPosition := 1;

//------------------------------------------>

Randomize;

SetComponentBorder(Memo1, Random(9998999));

SetComponentBorder(Button1, $FF00FF);

SetComponentBorder(Button2, $FF0000);

SetComponentBorder(Button3, $0000FF);

SetComponentBorder(Button4, $00FF00);

end;

procedure TForm1.Timer1Timer(Sender: TObject);

var

BM : TBitmap;

const

H = 80;

W = 120;

begin

BM := TBitmap.Create;

BM.LoadFromResourceName(HInstance,'Test');

//---------->

LeftPosition := LeftPosition + 1;

if LeftPosition = 4 then

LeftPosition := 0;

//---------->

RightPosition := RightPosition + 1;

if RightPosition = 5 then

RightPosition := 1;

//---------->

Image3.Canvas.CopyRect(Rect(0, 0, W, H),

BM.Canvas,

Rect(W * LeftPosition, 0, W * RightPosition, H));

//---------->

Memo1.Text := 'Layer Position : '+IntToStr(LeftPosition + 1)+#13#10+

{Or Layer Position : IntToStr(RightPosition)}

'Left Pos : '+IntToStr(LeftPosition)+', Right Pos : '+IntToStr(RightPosition)+#13#10+

'LP : '+IntToStr(LeftPosition * W)+', RP : '+IntToStr(RightPosition * W)+#13#10+

'--------------------------------------------------------------------'+#13#10+

'NB : '+#13#10+

'TImage/Image3 Height : 80, Width : 120'+#13#10+

'X * Y = 120 x 80 Pixel'+#13#10+

'LP : Left Position'+#13#10+

'RP : Right Position'+#13#10+

'Layer 1 = LP : 0, RP : 120'+#13#10+

'Layer 2 = LP : 120, RP : 240'+#13#10+

'Layer 3 = LP : 240, RP : 360'+#13#10+

'Layer 4 = LP : 320, RP : 480';

BM.Free;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

OnOff := OnOff + 1;

if OnOff = 2 then

OnOff := 0;

Label1.Caption := 'On/Off Position : '+InTToStr(OnOff)+#13#10+'Timer Status : '+Copy(Button3.Caption, 6, Length(Button3.Caption));

//-------------case OnOff of---------------->

Timer1.Enabled := not Timer1.Enabled;

case OnOff of

0 :

begin

Button3.Caption := 'Turn On';

end;

1 :

begin

Button3.Caption := 'Turn Off';

end;

end;

end;

procedure TForm1.Button4Click(Sender: TObject);

begin

IV := IV + 1;

if IV = 11 then

IV := 1;

Button4.Caption := 'Interval = '+IntToStr(IV * 100);

Timer1.Interval := IV * 100;

Timer3.Interval := IV * 100;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

Button2.Tag := Button2.Tag + 1;

if Button2.Tag = 2 then

Button2.Tag := 0;

//-------------case OnOff of---------------->

Timer3.Enabled := not Timer3.Enabled;

case Button2.Tag of

0 :

begin

Button2.Caption := 'Turn On';

end;

1 :

begin

Button2.Caption := 'Turn Off';

end;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

BM : TBitmap;

begin

BM := TBitmap.Create;

BM.LoadFromResourceName(HInstance,'Test');

//---------->

Button1.Tag := Button1.Tag + 1;

if Button1.Tag = 4 then

Button1.Tag := 0;

//-----Rect(Left, Top, Right, Bottom)----->

case Button1.Tag of

0 :

begin //Layer 1

Image1.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(0, 0, 120, 80));

end;

1 :

begin //Layer 2

Image1.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(120, 0, 240, 80));

end;

2 :

begin //Layer 3

Image1.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(240, 0, 360, 80));

end;

3 :

begin //Layer 4

Image1.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(360, 0, 480, 80));

end;

end;

end;

procedure TForm1.Timer2Timer(Sender: TObject);

const

MS : String = 'X-88 - [ZN Project] ';

begin

Timer2.Tag := Timer2.Tag + 1;

if Timer2.Tag = Length(MS) then

Timer2.Tag := 0;

Form1.Caption := Copy(MS, Timer2.Tag, Length(MS));

end;

procedure TForm1.Timer3Timer(Sender: TObject);

var

BM : TBitmap;

begin

BM := TBitmap.Create;

BM.LoadFromResourceName(HInstance,'Test');

//---------->

Timer3.Tag := Timer3.Tag + 1;

if Timer3.Tag = 4 then

Timer3.Tag := 0;

//-----Left, Top, Right, Bottom----->

case Timer3.Tag of

0 :

begin //Layer 1

Image2.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(0, 0, 120, 80));

end;

1 :

begin //Layer 2

Image2.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(120, 0, 240, 80));

end;

2 :

begin //Layer 3

Image2.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(240, 0, 360, 80));

end;

3 :

begin //Layer 4

Image2.Canvas.CopyRect(Rect(0, 0, 120, 80),

BM.Canvas,

Rect(360, 0, 480, 80));

end;

end;

end;

end.

another way,

var

I: Integer;

var

BM: TBitmap;

begin

BM: = TBitmap.Create;

BM.LoadFromResourceName (hInstance, 'Test');

/ / ----- Rect (Left, Top, Right, Bottom) ----->

if I = 0 then

begin

Image1.Canvas.CopyRect (Rect (0, 0, 120, 80),

BM.Canvas,

Rect (0, 0, 120, 80));

end

else

begin

if I = 1 then

begin

Blah blah blah

end

else

begin

if I = 2 thenbegin

Blah blah blah

end

else

begin

if I = 3 then

begin

Blah blah blah

else

I := 0;

Inc (I);

end;

Have Fun. :drunk:

  • Like 3
Sign in to follow this  


9 Comments


Recommended Comments

iNjECTOR

Posted

Brother


Great Jop..


Do you know what that mean, it maen we can design GFX Like GIF without any compoents


 


Again one of the best Res i ever used


 


Deep Thanx for care and sharing such precious res

Share this comment


Link to comment

Brother

Great Jop..

Do you know what that mean, it maen we can design GFX Like GIF without any compoents

 

Again one of the best Res i ever used

 

Deep Thanx for care and sharing such precious res

oh so you mean that, I just know :), Delphi 2010 has support format *. gif but can not run the animation, Gif Loader component that may be in there torry.net?! ... if you look at the asm tutorial created by Jowy :), if you like running the Delphi File.gif on easily and without additional components I think there is an easy way

1. create with html scripts, to load file.gif

2. file.html & file.gif enter into the resource,

3. extract from Resource to File eg: [ExtractFilePath (Apps.exeName) + 'file.html & ExtractFilePath (Apps.exeName) +' File.gif],

4. then add the TWebBrowser component,

WebBrowser1.Navigaton: = ExtractFilePath (Apps.exeName) + 'file.html';

I think this is easier, but it's weird :).

Share this comment


Link to comment
kimosabry

Posted

I want source code for the program against the payment of money ؟؟


Share this comment


Link to comment

I want source code for the program against the payment of money ؟؟

but I feel it's OOT, maybe I / others can help, please make inquiries on the Programming category, decide what kind of structure you want.

 

sorry about my English.

Share this comment


Link to comment

i cant get becoz i dont understand coding !!!! is there any way to make animation and use in my patch....


Share this comment


Link to comment

sorry, I just realized this a few days :), there was an error in this section:

 

procedure TForm1.Timer1Timer(Sender: TObject);
var
BM : TBitmap;
const
H = 80;
W = 120;
begin
BM := TBitmap.Create;
BM.LoadFromResourceName(HInstance,'Test');

 

Just change the parts marked red, please put on TForm1.FormCreate

because it can take a lot of memory usage

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×