GdiPlus[30]: IGPPen: 线帽
生活随笔
收集整理的這篇文章主要介紹了
GdiPlus[30]: IGPPen: 线帽
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
StartCap 和 EndCap 屬性分別用來讀寫兩段的線帽, 測試圖:
StartCap 和 EndCap 測試代碼:
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject); constCapArr: array[0..8] of Byte = (0, 1, 2, 3, $10, $11, $12, $13, $14); varGraphics: IGPGraphics;Pen: IGPPen;Pt1,Pt2: TGPPoint;i: Integer; beginPt1.Initialize(20, 20);Pt2.Initialize(200, 20);Graphics := TGPGraphics.Create(Handle);Pen := TGPPen.Create($FF2E8B57, 11);for i := 0 to Length(CapArr) - 1 dobeginPen.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.FormPaint(Sender: TObject); varGraphics: IGPGraphics;Pen: IGPPen;Pt1,Pt2: TGPPoint; beginPt1.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 方法一起設(shè)定 StartCap、EndCap、DashCap, 測試圖:
SetLineCap 測試代碼:
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject); varGraphics: IGPGraphics;Pen: IGPPen; beginGraphics := TGPGraphics.Create(Handle);Pen := TGPPen.Create($FFC71585, 11);Pen.DashStyle := DashStyleDashDot;Pen.SetLineCap(LineCapRoundAnchor, LineCapArrowAnchor, DashCapTriangle);Graphics.DrawLine(Pen, 20, 30, 300, 30); end;
總結(jié)
以上是生活随笔為你收集整理的GdiPlus[30]: IGPPen: 线帽的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。