お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





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

"グラデーション文字2"

この発言は
#00434 Fermion さんのグラデーション文字
に対するコメントです

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

■説明  フォームにグラデーション文字を表示させるサンプルです。可変部を 持つレコード型を用いずに、標準の関数を使用して RGB ⇔ Color 変換 をしています。  Form1 に Button1 を配置して、Button1 の OnClick イベントを以下 のようにして下さい。 ■参考  TColor ⇔ RGB については、FDELPHI/MES/6/814 からのツリーを参照。 ■サンプルコード //===================================================================== procedure TForm1.Button1Click(Sender: TObject); var Rect, GRect : TRect; W, H, i : Integer; Txt : String; StartColor, EndColor : TColor; RStep, GStep, BStep, R, G, B : 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 := $00FF0080; EndColor := $004080FF; R := GetRValue( StartColor ); G := GetGValue( StartColor ); B := GetBValue( StartColor ); RStep := ( GetRValue( EndColor ) - R ) div H; GStep := ( GetGValue( EndColor ) - G ) div H; BStep := ( GetBValue( EndColor ) - 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 Brush.Color := TColor( RGB( R, G, B ) ); FillRect( GRect ); Inc( GRect.Top ); Inc( GRect.Bottom ); R := R + RStep; G := G + GStep; B := B + BStep; end; end; end; //===================================================================== 98/03/07(土) 22:45 Fermion(KHF03264) Original document by Fermion 氏 ID:(KHF03264)



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

Copyright 1996-2002 Delphi Users' Forum