//畫貝塞爾曲線
var
g: TGPGraphics;
p: TGPPen;
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(255,0,0),2);
g.DrawBezier(p, 11,11, 88,333, 99,0, 222,111); {參數是畫筆與 4 個點的坐標}
p.Free;
g.Free;
end;
//使用 TGPPoint 或 TGPPointF
var
g: TGPGraphics;
p: TGPPen;
const
points: array[0..3] of TGPPoint = ((x:11; y:11),
(x:88; y:333),
(x:99; y:0),
(x:222; y:111));
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(255,0,0),2);
g.DrawBezier(p, points[0], points[1], points[2], points[3]); {用了 4 個常數點}
p.Free;
g.Free;
end;
//連續 Bezier 線
var
g: TGPGraphics;
p: TGPPen;
pts: array[0..6] of TGPPoint; //數組元素必須是 3 的倍數加 1
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(255,0,0),4);
pts[0].X := 77; pts[0].Y := 44;
pts[1].X := 66; pts[1].Y := 111;
pts[2].X := 88; pts[2].Y := 222;
pts[3].X := 111; pts[3].Y := 88;
pts[4].X := 132; pts[4].Y := 222;
pts[5].X := 222; pts[5].Y := 111;
pts[6].X := 256; pts[6].Y := 11;
g.DrawBeziers(p, PGPPoint(@pts), Length(pts));
p.Free;
g.Free;
end;