程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi GDI+學習記錄(11): 路徑漸變畫刷 - PathGradientBrush(2)

Delphi GDI+學習記錄(11): 路徑漸變畫刷 - PathGradientBrush(2)

編輯:Delphi

//設置路徑畫刷的中心點

var
  g: TGPGraphics;
  path: TGPGraphicsPath;
  pb: TGPPathGradIEntBrush;
  num: Integer;
const
  colors : array[0..0] of TGPColor = (aclAqua);
begin
  g := TGPGraphics.Create(Canvas.Handle);
  path:= TGPGraphicsPath.Create;
  path.AddEllipse(0, 0, 140, 70);
  pb:= TGPPathGradIEntBrush.Create(path);
  pb.SetCenterPoint(MakePoint(120, 40)); {設置中心點}
  pb.SetCenterColor(MakeColor(255, 0, 0, 255));
  num := 1;
  pb.SetSurroundColors(@colors, num);
  g.FillEllipse(pb, 0, 0, 140, 70);
  path.Free;
  pb.Free;
  g.Free;
end;

//使用灰度校正

var
  g: TGPGraphics;
  path: TGPGraphicsPath;
  pb: TGPPathGradIEntBrush;
  num: Integer;
const
  colors: array[0..0] of TGPColor = (aclAqua);
begin
  g := TGPGraphics.Create(Canvas.Handle);
  path := TGPGraphicsPath.Create;
  path.AddEllipse(0,0,166,88);
  pb := TGPPathGradIEntBrush.Create(path);
  pb.SetGamMacorrection(True); {使用灰度校正}
  num := 1;
  pb.SetSurroundColors(@colors, num);
  g.FillEllipse(pb, 0, 0, 166, 88);
  path.Free;
  pb.Free;
  g.Free;
end;

//多種顏色及位置

var
  g : TGPGraphics;
  pts: array[0..2] of TGPPoint;
  pb: TGPPathGradIEntBrush;
const
  colors: array[0..2] of TGPColor = (aclGreen, aclAqua, aclBlue);
  pos: array[0..2] of Single = (0.0, 0.25, 1.0); {顏色位置需要 >0、<1, 是百分百}
begin
  g := TGPGraphics.Create(Canvas.Handle);
  pts[0] := MakePoint(100, 0);
  pts[1] := MakePoint(200, 200);
  pts[2] := MakePoint(0, 200);
  pb:= TGPPathGradIEntBrush.Create(PGPPoint(@pts), 3); {根據點數組指針建立路徑畫刷}
  pb.SetInterpolationColors(@colors, @pos, 3); {設置顏色位置}
  g.FillRectangle(pb, 0, 0, 200, 200);
  pb.Free;
  g.Free;
end;

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