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 fade text in and out on a TCanvas 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
94
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to fade text in and out on a TCanvas

Answer:
1   
2   function TFadeEffect.FadeInText(Target: TCanvas; X, Y: integer; FText: string): 
3   TRect;
4   var
5     Pic: TBitmap;
6     W, H: integer;
7     PicRect, TarRect: TRect;
8   begin
9     Pic := TBitmap.Create;
10    Pic.Canvas.Font := Target.Font;
11    W := Pic.Canvas.TextWidth(FText);
12    H := Pic.Canvas.TextHeight(FText);
13    Pic.Width := W;
14    Pic.Height := H;
15    PicRect := Rect(0, 0, W, H);
16    TarRect := Rect(X, Y, X + W, Y + H);
17    Pic.Canvas.CopyRect(PicRect, Target, TarRect);
18    SetBkMode(Pic.Canvas.Handle, Transparent);
19    Pic.Canvas.TextOut(0, 0, FText);
20    FadeInto(Target, X, Y, Pic);
21    Pic.Free;
22    FadeInText := TarRect;
23  end;
24  
25  procedure TFadeEffect.FadeOutText(Target: TCanvas; TarRect: TRect; Orig: TBitmap);
26  var
27    Pic: TBitmap;
28    PicRect: TRect;
29  begin
30    Pic := TBitmap.Create;
31    Pic.Width := TarRect.Right - TarRect.Left;
32    Pic.Height := TarRect.Bottom - TarRect.Top;
33    PicRect := Rect(0, 0, Pic.Width, Pic.Height);
34    Pic.Canvas.CopyRect(PicRect, Orig.Canvas, TarRect);
35    FadeInto(Target, TarRect.Left, TarRect.Top, Pic);
36    Pic.Free;
37  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