Object TEasyBezierCurve

Unit

Declaration

type TEasyBezierCurve = object(TObject)

Description

Object representing an easy-to-use Bezier curve.

Curve is configured with approximate points, with configurable curve modes and transformation functions

Hierarchy

Overview

Fields

Protected FClosed: boolean;
Protected FCurves: array of record isCurvedToNext,isCurvedToPrevious: boolean; Center,ControlPoint,NextCenter: TPointF; end;
Protected FInvalidated: boolean;
Protected FMinimumDotProduct: single;
Protected FPoints: array of record Coord: TPointF; CurveMode: TEasyBezierCurveMode; end;

Methods

Public function ComputeLength: single;
Public function ToPoints: ArrayOfTPointF;
Protected function MaybeCurve(start1, end1, start2, end2: integer): boolean;
Protected function PointTransformNone(APoint: PPointF; AData: Pointer): TPointF;
Protected function PointTransformOffset(APoint: PPointF; AData: Pointer): TPointF;
Public procedure Clear;
Public procedure CopyToPath(ADest: IBGRAPath; AOffset: TPointF; AReverse: boolean = false); overload;
Public procedure CopyToPath(ADest: IBGRAPath; ATransformFunc: TEasyBezierPointTransformFunc; ATransformData: Pointer; AReverse: boolean = false); overload;
Public procedure CopyToPath(ADest: IBGRAPath); overload;
Public procedure Init;
Public procedure SetPoints(APoints: array of TPointF; ACurveMode: array of TEasyBezierCurveMode); overload;
Public procedure SetPoints(APoints: array of TPointF; ACurveMode: TEasyBezierCurveMode); overload;
Public procedure SetPoints(APoints: array of TPointF; ACurveMode: array of TEasyBezierCurveMode; AStart, ACount: integer); overload;
Public procedure SetPoints(APoints: array of TPointF; ACurveMode: TEasyBezierCurveMode; AStart, ACount: integer); overload;
Protected procedure ComputeQuadraticCurves;

Properties

Public property Closed: boolean read FClosed write SetClosed;
Public property CurveMode[AIndex: integer]: TEasyBezierCurveMode read GetCurveMode write SetCurveMode;
Public property CurveStartPoint: TPointF read GetCurveStartPoint;
Public property MinimumDotProduct: single read FMinimumDotProduct write SetMinimumDotProduct;
Public property Point[AIndex: integer]: TPointF read GetPoint write SetPoint;
Public property PointCount: integer read GetPointCount;

Description

Fields

Protected FClosed: boolean;

Is the curve is closed

Protected FCurves: array of record isCurvedToNext,isCurvedToPrevious: boolean; Center,ControlPoint,NextCenter: TPointF; end;

Computed Bézier control points

Protected FInvalidated: boolean;

Whether the curve need to be recomputed

Protected FMinimumDotProduct: single;

Minimum dot product to form a curve instead of an angle

Protected FPoints: array of record Coord: TPointF; CurveMode: TEasyBezierCurveMode; end;

Definition of the curve by the user

Methods

Public function ComputeLength: single;

Computes the total length of the Bezier curve

Public function ToPoints: ArrayOfTPointF;

Converts the Bezier curve into an array of points

Protected function MaybeCurve(start1, end1, start2, end2: integer): boolean;

Checks whether two vectors have the minimum dot product to suggest a curve. start1 and end1 are the indices for the first vector. start2 and end2 for the second vector.

Protected function PointTransformNone(APoint: PPointF; AData: Pointer): TPointF;

Fonction to apply no transformation

Protected function PointTransformOffset(APoint: PPointF; AData: Pointer): TPointF;

Fonction to apply an offset

Public procedure Clear;

Clears all points and resets the curve

Public procedure CopyToPath(ADest: IBGRAPath; AOffset: TPointF; AReverse: boolean = false); overload;

Copies the Bezier curve to a path object with an offset and optional reversal

Public procedure CopyToPath(ADest: IBGRAPath; ATransformFunc: TEasyBezierPointTransformFunc; ATransformData: Pointer; AReverse: boolean = false); overload;

Copies the Bezier curve to a path object with a custom transformation

Public procedure CopyToPath(ADest: IBGRAPath); overload;

Copies the Bezier curve to a path object

Public procedure Init;

Initializes the Bezier curve object

Public procedure SetPoints(APoints: array of TPointF; ACurveMode: array of TEasyBezierCurveMode); overload;

Sets the points and individual curve modes for each point

Public procedure SetPoints(APoints: array of TPointF; ACurveMode: TEasyBezierCurveMode); overload;

Sets the points and curve mode for the entire curve

Public procedure SetPoints(APoints: array of TPointF; ACurveMode: array of TEasyBezierCurveMode; AStart, ACount: integer); overload;

Sets a subset of points and individual curve modes for each of these points

Public procedure SetPoints(APoints: array of TPointF; ACurveMode: TEasyBezierCurveMode; AStart, ACount: integer); overload;

Sets a subset of points and a single curve mode for these points

Protected procedure ComputeQuadraticCurves;

Computes the control points for the classical quadratic curve

Properties

Public property Closed: boolean read FClosed write SetClosed;

Gets or sets whether to close the curve

Public property CurveMode[AIndex: integer]: TEasyBezierCurveMode read GetCurveMode write SetCurveMode;

Mode to use for each point

Public property CurveStartPoint: TPointF read GetCurveStartPoint;

Coordinates of the starting point

Public property MinimumDotProduct: single read FMinimumDotProduct write SetMinimumDotProduct;

Minimum dot product to form a curve rather than an angle when using cmAuto mode

Public property Point[AIndex: integer]: TPointF read GetPoint write SetPoint;

Coordinates of the points

Public property PointCount: integer read GetPointCount;

Number of points