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

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

編輯:Delphi

//設置多種周邊顏色

var
  g: TGPGraphics;
  path: TGPGraphicsPath;
  pb: TGPPathGradIEntBrush;
  colors: array[0..9] of TGPColor;
  num: Integer;
const
  pts : array[0..9] of TGPPoint =
   ((x:75 ; y:0 ), (x:100; y:50 ),
   (x:150; y:50 ), (x:112; y:75 ),
   (x:150; y:150), (x:75 ; y:100),
   (x:0 ; y:150), (x:37 ; y:75 ),
   (x:0 ; y:50 ), (x:50 ; y:50 ));
begin
  g := TGPGraphics.Create(Canvas.Handle);
  path:= TGPGraphicsPath.Create;
  path.AddLines(PGPPoint(@pts), 10);
  pb:= TGPPathGradIEntBrush.Create(path);
  pb.SetCenterColor(MakeColor(255, 255, 0, 0));
  colors[0] := MakeColor(255, 0, 0, 0);
  colors[1] := MakeColor(255, 0, 255, 0);
  colors[2] := MakeColor(255, 0, 0, 255);
  colors[3] := MakeColor(255, 255, 255, 255);
  colors[4] := MakeColor(255, 0, 0, 0);
  colors[5] := MakeColor(255, 0, 255, 0);
  colors[6] := MakeColor(255, 0, 0, 255);
  colors[7] := MakeColor(255, 255, 255, 255);
  colors[8] := MakeColor(255, 0, 0, 0);
  colors[9] := MakeColor(255, 0, 255, 0);
  num := 10;
  pb.SetSurroundColors(@colors, num); {設置多種周邊顏色}
  g.FillPath(pb, path);
  pb.SetGamMacorrection(True); {使用灰度校正}
  g.TranslateTransform(200.0, 0.0);
  g.FillPath(pb, path);
  path.Free;
  pb.Free;
  g.Free;
end;

//描繪在不同的區域

var
  g : TGPGraphics;
  pb: TGPPathGradIEntBrush;
  p: TGPPen;
  colors: array[0..4] of TGPColor;
  num: Integer;
const
  pts: array[0..4] of TGPPointF =
  ((x: 0.0 ; y: 0.0),
   (x: 160.0; y: 0.0),
   (x: 160.0; y: 200.0),
   (x: 80.0 ; y: 150.0),
   (x: 0.0 ; y: 200.0));
begin
  g := TGPGraphics.Create(Canvas.Handle);
  pb:= TGPPathGradIEntBrush.Create(PGPPointF(@pts), 5);
  colors[0] := MakeColor(255, 255, 0, 0);
  colors[1] := MakeColor(255, 0, 255, 0);
  colors[2] := MakeColor(255, 0, 255, 0);
  colors[3] := MakeColor(255, 0, 0, 255);
  colors[4] := MakeColor(255, 255, 0, 0);
  num := 5;
  pb.SetSurroundColors(@colors, num);
  pb.SetCenterColor(MakeColor(255, 255, 255, 255));
  g.FillRectangle(pb, MakeRect(0, 0, 180, 220));
  p := TGPPen.Create(aclBlack);
  g.DrawRectangle(p, MakeRect(0, 0, 180, 220));
  p.Free;
  pb.Free;
  g.Free;
end;

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