AddArcToPath
向量圖形、路徑定義與繪製
描述
在目前路徑加入圓弧。弧以中心點 (CenterX, CenterY) 為圓心繪製,半徑等於中心到路徑目前點的距離,掃過 TotalAngle 度。呼叫後的目前點就是弧的終點,之後的 AddLineToPath 或 AddArcToPath 呼叫會從那裡接續
語法
Delphi
Function TPDFlib.AddArcToPath(CenterX, CenterY, TotalAngle: Double): Integer;
ActiveX
Function PDFlib::AddArcToPath(CenterX As Double, CenterY As Double, TotalAngle As Double) As Long
DLL
int DLAddArcToPath(int InstanceID, double CenterX, double CenterY, double TotalAngle);
參數
| CenterX | 弧圓心的水平座標。 |
|---|---|
| CenterY | 弧圓心的垂直座標。 |
| TotalAngle | 角度掃角(度)。正值順時針掃;負值逆時針掃。值不可為零。360(或 -360)畫出完整圓。 |
傳回值
| 0 | Failed — no document is open, no path has been started, or TotalAngle is zero. |
|---|---|
| 1 | 弧已加入目前路徑。 |
備註
半徑由目前點(由最近一次 StartPath、AddLineToPath、AddCurveToPath 或前一次 AddArcToPath 設定)與本呼叫傳入中心點之間的距離隱含決定。要畫完整的圓,先用 StartPath 移到圓周上任一點,再以想要的中心與 360 掃角呼叫 AddArcToPath。
The arc is rendered as a chain of cubic Bézier segments, accurate to within sub-pixel tolerance for typical PDF page sizes.
範例
// A pie slice — straight edge, arc, straight edge back to centre
PDF.SetFillColor(0.7, 0.2, 0.2);
PDF.StartPath(200, 200); // pie centre
PDF.AddLineToPath(280, 200); // out to circle (radius 80, angle 0°)
PDF.AddArcToPath(200, 200, 90); // sweep 90° clockwise
PDF.ClosePath; // back to the centre
PDF.DrawPath(2); // 2 = fill and outline
// A complete circle drawn as a single arc
PDF.StartPath(300, 100);
PDF.AddArcToPath(250, 100, 360);
PDF.ClosePath;
PDF.DrawPath(0);另見
StartPath, AddLineToPath, AddCurveToPath, AddBoxToPath, DrawPath, DrawPathEvenOdd