お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





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

"RE^2:グラデーション文字"

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

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

 クリップリージョンの廃棄に問題がありそうなので、、(((^^;)  m(_"_)m ■サンプルコード //===================================================================== 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 : Extended; Rgn : HRGN; 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 := clAqua;//$00FF0080; EndColor.Color := clBlack;//$004080FF; PaintColor := StartColor; RStep := ( EndColor.R - StartColor.R ) / H; GStep := ( EndColor.G - StartColor.G ) / H; BStep := ( EndColor.B - StartColor.B ) / H; SetBkMode( Handle, TRANSPARENT ); BeginPath( Handle ); DrawText( Handle, PChar( Txt ), -1, Rect, DT_SINGLELINE or DT_VCENTER or DT_CENTER ); EndPath( Handle ); Rgn := PathToRegion( Handle ); try if SelectClipRgn( Handle, Rgn ) > NULLREGION then begin GRect.TopLeft := Rect.TopLeft; GRect.BottomRight := Point( Rect.Right, GRect.Top + 1 ); for i := 0 to H do begin with PaintColor do begin R := StartColor.R + Trunc( RStep * i ); G := StartColor.G + Trunc( GStep * i ); B := StartColor.B + Trunc( BStep * i ); Brush.Color := Color; FillRect( GRect ); end; Inc( GRect.Top ); Inc( GRect.Bottom ); end; SelectClipRgn( Handle, 0 ); end; finally DeleteObject( Rgn ); end; end; end; //===================================================================== 98/03/13(金) 00:28 Fermion [KHF03264] Original document by Fermion 氏 ID:(KHF03264)



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

Copyright 1996-2002 Delphi Users' Forum