Sign in Join
FPDoc Onlineexperiment

Arc2Bezier procedure

In unit GraphMath

Converts an Arc and ArcLength into a Bezier Approximation of the Arc.

Declaration

pascal
procedure Arc2Bezier(X: LongInt; Y: LongInt; Width: LongInt; 
 Height: LongInt; Angle1: Extended; 
 Angle2: Extended; Rotation: Extended; 
 var Points: TBezier)

Description

Use Arc2Bezier to convert an elliptical arc into a Bezier approximation of the arc.

The arc is defined by a rectangle which bounds the full ellipse. The rectangle has the specified Width and Height, its top/left corner is at the point X, Y. The start of the arc is given by the eccentric Angle1, and its length is given by eccentric Angle2. Both angles are expressed in 1/16th of a degree, a full circle, for example, equals to 5760 (16*360). A positive value of Angle2 means counter-clockwise while a negative value means clockwise direction. Zero degrees is at the 3 o'clock position.

The Rotation parameter accepts an angle for a rotated ellipse - for a non-rotated ellipse this value would be 0, or 360*16.

If the angle length is greater than 90 degrees or is equal to 0, the procedure automatically exits, as Bezier cannot accurately approximate any angle greater then 90 degrees, and in fact for best results no angle greater than 45 should be converted, instead an array of Beziers should be created, each Bezier describing a portion of the total arc no greater than 45 degrees.

An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.