Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create a wipe effect using regions Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
29-Aug-02
Category
Graphic
Language
Delphi 2.x
Views
98
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

How to create a wipe effect using regions

Answer:

This wipes anti-clockwise:

1   unit ClockWipe;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
7   ExtCtrls, StdCtrls;
8   
9   type
10    TPkt = array[0..361] of TPoint;
11  
12  type
13    TForm1 = class(TForm)
14      Image1: TImage;
15      Image2: TImage;
16      Button1: TButton;
17      procedure FormPaint(Sender: TObject);
18      procedure Button1Click(Sender: TObject);
19    private
20      procedure ClockWipe(re: TRect; Bmp: TBitmap);
21      procedure SetPolygonRegion(Pkt: TPkt; PktCount: Integer; Bmp: TBitmap);
22      function GetArcPoint(cPoint: TPoint; radius, winkel: Integer): TPoint;
23    public
24      { Public Declarations }
25    end;
26  
27  var
28    Form1: TForm1;
29  
30  implementation
31  
32  {$R *.DFM}
33  
34  procedure TForm1.Button1Click(Sender: TObject);
35  begin
36    Canvas.Draw(0, 0, Image1.Picture.Bitmap);
37    ClockWipe(Image2.Picture.Bitmap.Canvas.ClipRect, Image2.Picture.Bitmap);
38  end;
39  
40  procedure TForm1.FormPaint(Sender: TObject);
41  begin
42    Canvas.Draw(0, 0, Image1.Picture.Bitmap);
43  end;
44  
45  procedure TForm1.ClockWipe(re: TRect; Bmp: TBitmap);
46  var
47    radius, winkel, cv: Integer;
48    cP: TPoint;
49    Pkt: TPkt;
50  begin
51    radius := Round(Sqrt(Sqr((re.right - re.left) div 2) + Sqr((re.bottom - re.top) 
52  div 2)));
53    cP := Point((re.right - re.left) div 2, (re.bottom - re.top) div 2);
54    Pkt[0] := cP;
55    for winkel := 0 to 360 do
56      Pkt[winkel + 1] := GetArcPoint(cP, radius, winkel + 90);
57    for cv := 0 to 361 do
58      if (cv - 1) / 20 = (cv - 1) div 20 then
59      begin
60        Sleep(50);
61        SetPolygonRegion(Pkt, cv + 1, Image2.Picture.Bitmap);
62      end;
63  end;
64  
65  procedure TForm1.SetPolygonRegion(Pkt: TPkt; PktCount: Integer; Bmp: TBitmap);
66  var
67    Region: HRGN;
68  begin
69    Region := CreatePolygonRGN(Pkt, PktCount, WINDING);
70    if Region <> 0 then
71    begin
72      SelectClipRgn(Canvas.handle, Region);
73      Canvas.Draw(0, 0, Bmp);
74      SelectClipRgn(Canvas.handle, 0);
75      DeleteObject(Region);
76    end;
77  end;
78  
79  function TForm1.GetArcPoint(cPoint: TPoint; radius, winkel: Integer): TPoint;
80  begin
81    result.x := Round(cPoint.x + radius * Cos(winkel * 2 * pi / 360));
82    result.y := Round(cPoint.y - radius * Sin(winkel * 2 * pi / 360));
83  end;
84  
85  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC