お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"グラデーション文字"

この発言に対し以下のコメントが寄せられています
#00435 Fermion さん グラデーション文字2
#00437 Fermion さん RE:グラデーション文字

■説明  フォームにグラデーション文字を表示させるサンプルです。  Form1 に Button1 を配置して、Button1 の OnClick イベントを以下 のようにして下さい。 ■参考  TColor ⇔ RGB については、FDELPHI/MES/6/814 からのツリーを参照。 ■サンプルコード //===================================================================== procedure TForm1.Button1Click(Sender: TObject); type TRGB = packed record case RGB: Boolean of False :( Color: TColor ); True :( R: Byte; G: Byte; B: Byte; P: Byte ); end; var Rect, GRect : TRect; W, H, i : Integer; Txt : String; StartColor, EndColor, PaintColor : TRGB; RStep, GStep, BStep : Byte; begin Txt := '★ぐらで〜しょん???★'; Rect := ClientRect; with Canvas do begin with Font do begin Name := 'MS P明朝'; Size := 32; Style := Style + [fsBold]; end; W := TextWidth( Txt ); H := TextHeight( Txt ); with Rect do begin TopLeft := Point(( Right - Left - W ) div 2, ( Bottom - Top - H ) div 2 ); BottomRight := Point( Left + W, Top + H ); end; StartColor.Color := $00FF0080; EndColor.Color := $004080FF; PaintColor := StartColor; RStep := ( EndColor.R - StartColor.R ) div H; GStep := ( EndColor.G - StartColor.G ) div H; BStep := ( EndColor.B - StartColor.B ) div H; SetBkMode( Handle, TRANSPARENT ); BeginPath( Handle ); DrawText( Handle, PChar( Txt ), -1, Rect, DT_SINGLELINE or DT_VCENTER or DT_CENTER ); EndPath( Handle ); SelectClipPath( Handle, RGN_AND ); GRect.TopLeft := Rect.TopLeft; GRect.BottomRight := Point( Rect.Right, GRect.Top + 1 ); for i := Rect.Top to Rect.Bottom - 1 do begin with PaintColor do begin Brush.Color := Color; FillRect( GRect ); R := R + RStep; G := G + GStep; B := B + BStep; end; Inc( GRect.Top ); Inc( GRect.Bottom ); end; end; end; //===================================================================== 98/03/07(土) 22:14 Fermion(KHF03264) Original document by Fermion 氏 ID:(KHF03264)



ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum