設定畫筆的 CompoundArray 屬性可得到複合畫筆.它對應的類型是 IGPCompoundArray (IGPCompoundArray = IGPArray<Single>).如果複合畫筆是 X 條線, 則數組需要 2*X 個元素; 元素從外向裡分別表示線的起點和終點的比例值.uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var Graphics: IGPGraphics; Pen: IGPPen;
測試:測試代碼:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
IGPGraphicsPath.Flatten(); //把路徑中的曲線轉換為近似直線段(路徑中只有 Bezier 線和直線).IGPGraphicsPath.Outline(); //同 Flatten();IGPGraphicsPath.Warp(); //四邊形或平行四邊形扭曲. IGPGraphicsPath.Widen(); //把輪廓轉換為範圍.IGPGraphicsPath.Transform(); //矩陣變換;
通過畫筆的 DashStyle 屬性可設定或讀取虛線樣式.通過 SetDashPattern 方法或 DashPattern 屬性可自訂虛線樣式.通過 DashPattern 屬性還可以讀出已有樣式定義時的數組.自訂虛線樣式樣式時, 需要元素數是雙數的數組數組, 元素值依次表示實線與空白的長度.通過 DashOffset 屬性可設定虛線位移.系統提供的虛線樣式效果:自訂的兩種樣式效果:虛線位移效果:測試系統提供的虛線樣式:uses GdiPlus;procedure
測試:測試代碼:uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var Graphics: IGPGraphics; Brush: IGPPathGradientBrush; Rect: TGPRect; Path: IGPGraphicsPath;begin Graphics := TGPGraphics.Create(Handle); Rect.Initialize(10, 10, 180, 100);
StartCap 和 EndCap 屬性分別用來讀寫兩段的線帽, 測試圖:StartCap 和 EndCap 測試代碼:uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);const CapArr: array[0..8] of Byte = (0, 1, 2, 3, $10, $11, $12, $13, $14);var Graphics: IGPGraphics; Pen: IGPPen; Pt1,Pt2:
測試:測試代碼:uses GdiPlus, GdiPlusHelpers;procedure TForm1.FormPaint(Sender: TObject);const C1 = $FF000000; C2 = $FFFF0000; C3 = $FFFFFF00; C4 = $FFFF0000; C5 = $FF000000;var Brush: IGPPathGradientBrush; Rect: TGPRect; Path: IGPGraphicsPath;
自訂線帽可以通過兩個介面: IGPCustomLineCap、IGPAdjustableArrowCap.後者繼承與前者, 專用於修改箭頭線帽.IGPAdjustableArrowCap 測試:IGPAdjustableArrowCap 測試代碼:uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var Graphics: IGPGraphics; Pen: IGPPen; Cap1,Cap2:
測試:uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var Graphics: IGPGraphics; Brush: IGPSolidBrush; Pt: TGPPointF; Font: IGPFont;begin Graphics := TGPGraphics.Create(Handle); Pt.Initialize(10, 10); Brush := TGPSolidBrush.Create($FFFF0
LineJoin 測試:LineJoin 測試代碼:uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);const Pts: array[0..2] of TGPPoint = ((X:90;Y:80), (X:240;Y:30), (X:240;Y:80));var Graphics: IGPGraphics; Pen: IGPPen;begin Graphics := TGPGraphics.Create(Handle);
IGPFontFamily 的基本使用:uses GdiPlus, GdiPlusHelpers;procedure TForm1.FormPaint(Sender: TObject);const Pt: TGPPointF = (X:10; Y:10);var FontFamily: IGPFontFamily; Font: IGPFont; Brush: IGPSolidBrush;begin FontFamily := TGPFontFamily.Create('微軟雅黑');
IGPPrivateFontCollection.AddFontFile: 從檔案載入字型;IGPPrivateFontCollection.AddMemoryFont: 從記憶體載入字型AddFontFile 測試:uses GdiPlus;function GetFontsDirectory: string;var Len: Integer; buf: array[0..MAX_PATH-1] of Char;begin GetWindowsDirectory(buf, Length(
DrawLine();DrawLines();DrawArc();DrawBezier();DrawBeziers();DrawRectangle();DrawRectangles();DrawEllipse();DrawPie();DrawPolygon();DrawCurve();DrawClosedCurve();FillRectangle();FillRectangles();FillPolygon();FillEllipse();FillPie();FillClosedCurve();
SetBlendBellShape 方法: 建立基於鐘形曲線的漸層過渡過程;SetBlendTriangularShape 方法: 建立一個從中心色向兩端單個顏色線性過渡的線性漸層過程.兩個方法好像區別不大.SetBlendBellShape 測試:SetBlendTriangularShape 測試:SetBlendBellShape 測試代碼:uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var Graphics:
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; Button2: TButton; procedure Button1Click(Sender:
路徑是一組圖形命令,
LinearColors //屬性; 擷取或設定漸層的起始色和結束色.Rectangle //屬性; 擷取定義漸層的起始點和終結點的矩形地區.WrapMode //屬性; 擷取或設定 WrapMode 枚舉, 指定畫刷環繞模式; 感覺它沒有存在的必要.TranslateTransform //方法; 平移.ScaleTransform //方法; 放縮.RotateTransform //方法; 旋轉.Transform //屬性;
Color 是畫筆的基本屬性, 比較有意思的是可以通過畫刷來建立畫筆.五種畫刷都可以, 但使用實心畫刷就沒有意義了; 建立後, 通過畫筆的 PenType 能知道是通過什麼畫刷建立的; 也能通過 Brush 屬性擷取回畫刷.下面的例子只是測試了通過陰影畫刷建立畫筆:uses GdiPlus, GdiPlusHelpers;procedure TForm1.FormPaint(Sender: TObject);var Pen: IGPPen; Brush: IGPBrush;begin
IGPGraphicsPath.IsVisible //指定點是否在路徑內IGPGraphicsPath.IsOutlineVisible //指定點是否在路徑輪廓上本例測試圖:本例代碼:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm)
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var Graphics: IGPGraphics; BlackPen, GreenPen: IGPPen; Rect: TGPRect;begin Rect.Initialize(20, 20, 80, 80); Graphics := TGPGraphics.Create(Handle); BlackPen := TGPPen.Create($FF000000, 1.