程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> GdiPlus[19]: IGPPathGradientBrush 之 SetCenterPoint

GdiPlus[19]: IGPPathGradientBrush 之 SetCenterPoint

編輯:Delphi

 測試效果圖:

GdiPlus[19]: IGPPathGradientBrush 之 SetCenterPoint

  測試代碼:

unit Unit1; 
 
interface 
 
uses 
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
 Dialogs; 
 
type 
 TForm1 = class(TForm) 
  procedure FormPaint(Sender: TObject); 
  procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 
 end; 
 
var 
 Form1: TForm1; 
 
implementation 
 
{$R *.dfm}  
 
uses GdiPlus, GdiPlusHelpers; 
 
var 
 Pt: TGPPointF; 
 
procedure TForm1.FormPaint(Sender: TObject); 
var 
 Brush: IGPPathGradIEntBrush; 
 Rect: TGPRect; 
 Path: IGPGraphicsPath; 
begin 
 Rect.Initialize(10, 10, 200, 150); 
 Path := TGPGraphicsPath.Create; 
 Path.AddEllipse(Rect); 
 
 Brush := TGPPathGradIEntBrush.Create(Path); 
 Brush.CenterColor := $FF00FF00; 
 Brush.SetSurroundColors([$FF000000]); 
 
 Brush.SetCenterPoint(Pt); 
 
 Canvas.ToGPGraphics.FillEllipse(Brush, Rect); 
 Canvas.ToGPGraphics.DrawRectangle(TGPPen.Create($FFFF0000), Pt.X-3, Pt.Y-3, 6, 6); 
end; 
 
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 
begin 
 Pt.X := X; 
 Pt.Y := Y; 
 Repaint; 
end; 
 
end. 


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved