## Bezier curves and anti-aliasing

Please discuss general Delphi programming topics here.

### Bezier curves and anti-aliasing

1. how calculate where should be positioned points and control points in bezier curve (windows implementation), so the curve would go trouught specified list of points?

2. How to anti-alias that curve, so it would look smooth?
Johnny_Bit
VIP Member

Posts: 455
Joined: June 15th, 2003, 9:56 am

Cheers,
Stefan

Stefan
Moderator

Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands

Johnny_Bit
VIP Member

Posts: 455
Joined: June 15th, 2003, 9:56 am

indeed

umm, would anti-aliasing the line-pieces of the curve be enough?

Stefan
Moderator

Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands

I quite don't understand...
Johnny_Bit
VIP Member

Posts: 455
Joined: June 15th, 2003, 9:56 am

Here's some code I use in TExtGraph to get all the line-parts of a bézier curve:

Code: Select all
  BeginPath(Canvas.Handle);  PolyBezier(Canvas.Handle, points, 4);  EndPath(Canvas.Handle);  FlattenPath(Canvas.Handle);  NumLine := getpath(Canvas.Handle, lpPoints, lpTypes, 0);  setlength(lppoints, NumLine);  setlength(lptypes, NumLine);  GetPath(Canvas.Handle, lppoints[0], lptypes[0], NumLine);  for i := 0 to NumLine-1 do begin    case lpTypes[i] of      PT_MOVETO: Canvas.MoveTo(lppoints[i].x, lppoints[i].y);      PT_LINETO: Canvas.LineTo(lppoints[i].x, lppoints[i].y);    end;  end;

after this you could (in the for-loop) anti-alias all the lines...

Stefan
Moderator

Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands