//画贝塞尔曲线
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;

var
  g:TGPGraphics;
  p:TGPPen;
  pts:array[0..6] of TGPPoint;  //数组元素必须是 3 的倍数加 1
begin
  g:=TGPGraphics.Create(Canvas.Handle);
  g.Clear(aclWhite);
  p:=TGPPen.Create(aclRed,4);

  pts[0]:=MakePoint(30,44);
  pts[1]:=MakePoint(80,111);
  pts[2]:=MakePoint(88,222);
  pts[3]:=MakePoint(111,88);
  pts[4]:=MakePoint(132,222);
  pts[5]:=MakePoint(222,111);
  pts[6]:=MakePoint(256,11);

  g.DrawBeziers(p,PGPPoint(@pts),Length(pts));
  p.Free;
  g.Free;
end;
posted on 2010-12-08 17:50  巅枫  阅读(748)  评论(0编辑  收藏  举报