专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »PHP教程 » GdiPlus[30]: IGPPen: 线帽 »正文

GdiPlus[30]: IGPPen: 线帽

来源: 发布时间:星期四, 2009年12月17日 浏览:0次 评论:0


  StartCap 和 EndCap 属性分别用来读写两段线帽, 测试图:



  StartCap 和 EndCap 测试代码:

uses GdiPlus; 
 
procedure TForm1.FormPa(Sender: TObject); 
const 
 CapArr: .gif' />[0 ..8 ] of Byte = (0 , 1, 2, 3, $10, $11, $12, $13, $14); 
var 
 Graphics: IGPGraphics; 
 Pen: IGPPen; 
 Pt1,Pt2: TGPPo; 
 i: Integer; 
begin 
 Pt1.Initialize(20, 20); 
 Pt2.Initialize(200, 20); 
 Graphics := TGPGraphics.Create(Handle); 
 Pen := TGPPen.Create($FF2E8B57, 11); 
 
 for i := 0 to Length(CapArr) - 1 do 
 begin 
  Pen.StartCap := TGPLineCap(CapArr[i]); 
  Pen.EndCap := Pen.StartCap; 
  Graphics.DrawLine(Pen, Pt1, Pt2); 
  Graphics.TranslateTransform(0, Pt1.Y * 1.5); 
 end; 
end; 


  DashCap 属性用来读写虚线线帽, 这在实线中没有效果; 测试图:



  DashCap 测试代码:

uses GdiPlus; 
 
procedure TForm1.FormPa(Sender: TObject); 
var 
 Graphics: IGPGraphics; 
 Pen: IGPPen; 
 Pt1,Pt2: TGPPo; 
begin 
 Pt1.Initialize(20, 20); 
 Pt2.Initialize(240, 20); 
 Graphics := TGPGraphics.Create(Handle); 
 Pen := TGPPen.Create($FF4169E1, 11); 
 Pen.DashStyle := DashStyleDashDot; 
 
 Pen.DashCap := DashCapFlat; 
 Graphics.DrawLine(Pen, Pt1, Pt2); 
 Graphics.TranslateTransform(0, Pt1.Y * 1.5); 
 
 Pen.DashCap := DashCapRound; 
 Graphics.DrawLine(Pen, Pt1, Pt2); 
 Graphics.TranslateTransform(0, Pt1.Y * 1.5); 
 
 Pen.DashCap := DashCapTriangle; 
 Graphics.DrawLine(Pen, Pt1, Pt2); 
end; 


  可通过 SetLineCap 思路方法起设定 StartCap、EndCap、DashCap, 测试图:



  SetLineCap 测试代码:

uses GdiPlus; 
 
procedure TForm1.FormPa(Sender: TObject); 
var 
 Graphics: IGPGraphics; 
 Pen: IGPPen; 
begin 
 Graphics := TGPGraphics.Create(Handle); 
 Pen := TGPPen.Create($FFC71585, 11); 
 Pen.DashStyle := DashStyleDashDot; 
 
 Pen.SetLineCap(LineCapRoundAnchor, LineCapArrowAnchor, DashCapTriangle); 
 
 Graphics.DrawLine(Pen, 20, 30, 300, 30); 
end; 


标签:
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: