GDI+ 學習記錄(17): 曲線 - Curve

weixin_33711641發表於2007-12-27
//畫曲線
var
  g: TGPGraphics;
  p: TGPPen;
  pts: array[0..4] of TGPPoint;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(MakeColor(255,0,0),4);

  pts[0].X := 11;  pts[0].Y := 11;
  pts[1].X := 66;  pts[1].Y := 66;
  pts[2].X := 88;  pts[2].Y := 222;
  pts[3].X := 111; pts[3].Y := 111;
  pts[4].X := 222; pts[4].Y := 88;

  g.DrawCurve(p, PGPPoint(@pts), Length(pts));

  p.Free;
  g.Free;
end;


//指定曲度
var
  g: TGPGraphics;
  p: TGPPen;
  pts: array[0..4] of TGPPoint;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(MakeColor(255,0,0),4);

  pts[0].X := 11;  pts[0].Y := 11;
  pts[1].X := 66;  pts[1].Y := 66;
  pts[2].X := 88;  pts[2].Y := 222;
  pts[3].X := 111; pts[3].Y := 111;
  pts[4].X := 222; pts[4].Y := 88;

  g.DrawCurve(p, PGPPoint(@pts), Length(pts), 0.25); //指定曲度為 0.25; 預設是 0.5

  p.Free;
  g.Free;
end;


//繪製曲線的部分
var
  g: TGPGraphics;
  p: TGPPen;
  pts: array[0..4] of TGPPoint;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(MakeColor(255,0,0),4);

  pts[0].X := 11;  pts[0].Y := 11;
  pts[1].X := 66;  pts[1].Y := 66;
  pts[2].X := 88;  pts[2].Y := 222;
  pts[3].X := 111; pts[3].Y := 111;
  pts[4].X := 222; pts[4].Y := 88;

  g.DrawCurve(p, PGPPoint(@pts), Length(pts), 1, 2, 0);
  {引數 3 指定從第幾個點開始; 引數 4 指示繪製幾段; 引數 5 是曲度為 0 時就成了連續的直線}

  p.Free;
  g.Free;
end;

相關文章