随笔 - 2146  文章 - 97 评论 - 11765 trackbacks - 253

//画贝塞尔曲线
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;
posted on 2007-12-27 19:04 万一 阅读(...) 评论(...) 编辑 收藏