FlattenCBezier

function FlattenCBezier(const pt1, pt2, pt3, pt4: TPointD): TArrayOfPointD; overload;

function FlattenCBezier(const pts: TArrayOfPointD): TArrayOfPointD; overload;

function FlattenCBezier(const pts: TArrayOfArrayOfPointD): TArrayOfArrayOfPointD; overload;


uses Image32, Image32_PNG, Image32_vector, Image32_Draw;
...
var
  img: TImage32;
  path, path2: TArrayOfPointD;
  rec: TRect;
begin
  img := TImage32.Create(256,256);

  rec := img.Bounds;
  Windows.InflateRect(rec, -30,-10);
  Windows.OffsetRect(rec, 0, 60);
  with rec do //construct a bezier curve
    path := FlattenCBezier(PointD(left, top), PointD(left, bottom),
      PointD(right, bottom), PointD(right, top));
  //draw the bezier curve
  DrawLine(img, path, 10, clMaroon32, esRound);
  //draw a couple of 'points'
  DrawPoint(img, PointD(32,25) , 25, clBlue32);
  DrawPoint(img, PointD(256-32,25) , 25, clBlue32);

  img.SaveToFile('line2.png');
  img.Free;
end;
      

See Also

FlattenCSpline, FlattenQBezier