Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Bezier Curves in Firemonkey



Permlink Replies: 2 - Last Post: Apr 2, 2018 5:41 AM Last Post By: Alex Shy
Herbert Sauro

Posts: 46
Registered: 10/30/09
Bezier Curves in Firemonkey
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 16, 2014 12:42 PM
Before I roll my own I was wondering if any knows if Firemonkey (XE6) has native support for drawing Bezier curves? I noticed the Path methods QuadCurve and SmoothCurve, documentation is however sparse and the source code suggests these don't draw bezier curves, not sure what they draw.
Herbert Sauro

Posts: 46
Registered: 10/30/09
Re: Bezier Curves in Firemonkey
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 16, 2014 1:02 PM   in response to: Herbert Sauro in response to: Herbert Sauro
Herbert Sauro wrote:
Before I roll my own I was wondering if any knows if Firemonkey (XE6) has native support for drawing Bezier curves? I noticed the Path methods QuadCurve and SmoothCurve, documentation is however sparse and the source code suggests these don't draw bezier curves, not sure what they draw.

Just answered my own question, CurveTo appears to draw a Bezier curve, if you drop a TPaintBox on a form and add the following code to the OnPaint event , you'll get a Bezier curve (in XE6).

procedure TForm1.PaintBoxPaint(Sender: TObject; Canvas: TCanvas);
var path : TPathData;
begin
path := TPathData.Create;
try
path.MoveTo(TPointF.Create (10,100));
path.CurveTo(TPointF.Create(100,10),TPointF.Create(150,150), TPointF.Create(200,100));

Canvas.Stroke.Thickness := 2;
Canvas.Stroke.Color := claRed;
Canvas.BeginScene;
Canvas.DrawPath(path, 1.0);
Canvas.EndScene;
finally
path.Free;
end;
end;
Alex Shy

Posts: 11
Registered: 8/9/07
Re: Bezier Curves in Firemonkey
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 2, 2018 5:16 AM   in response to: Herbert Sauro in response to: Herbert Sauro
Fixed code for Berlin and newer:

procedure TForm2.FormPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
var path : TPathData;
begin
path := TPathData.Create;
try
path.MoveTo(TPointF.Create (10,100));
path.CurveTo (TPointF.Create(100,10),TPointF.Create(150,150),
TPointF.Create(200,100));
Canvas.Stroke.Thickness := 2;
Canvas.Stroke.Kind := TBrushKind.Solid;
Canvas.Stroke.Color := TAlphaColorRec.Red;
Canvas.BeginScene;
Canvas.DrawPath(path, 1.0);
Canvas.EndScene;
finally
path.Free;
end;
end;

Edited by: Alex Shy on Apr 2, 2018 3:40 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02