1.9 class bezier_curve

Class bezier_curve implements Bezier curves. A bezier smooth curve is a curve from bezier_curve<-start to bezier_curve<-end using either one or two control-points. They are used to create a smooth connection from a certain point leaving at a defined direction to another point arriving in some direction.

XPCE's class bezier_curve is a subclass of class joint, inheriting the possibility to have arrow objects at either end of the curve.

To get a feeling for the behaviour of this class, please try PceDraw from the demo programs (File/Demo Programs).

When bezier_curve->selected, the system will show the control-points connected by dotted lines.

A good description of the details on Bezier curves can be found at http://graphics.cs.ucdavis.edu/CAGDNotes/ See also class path.

1.9.1 Instance variables

bezier_curve <- control1: point
The attributes bezier_curve<-control1 and bezier_curve<-control2 define the Bezier curve's control-points. If bezier_curve<-control2 = @nil, the curve has only a single control-point and is known as a quadratic Bezier curve. If the second control point is specified, it is known as a cubic Bezier curve.

The curve departs from bezier_curve<-start in the direction of bezier_curve<-control1 and ends in bezier_curve<-end from the direction of bezier_curve<-control2 (or bezier_curve<-control1 if bezier_curve<-control2 is @nil. Unlike class path, the curve does not go through its control-points.

bezier_curve <- control2: point*
Inherits description from: bezier_curve-control1

1.9.2 Send methods

bezier_curve ->control1: point
1st Control-point of the Bezier curve.
bezier_curve ->control2: point*
Inherits description from: bezier_curve-control1, bezier_curve->control1
bezier_curve ->geometry: x=[int], y=[int], width=[int], height=[int]
The graphical->geometry method is redefined by class bezier to move the bezier curve.
bezier_curve ->initialise: start=point, end=point, control1=point, control2=[point]*
Create a bezier_curve object starting at start going to end using either one (quadratic) or two (cubic) control-points.
bezier_curve ->selected: bool
Refines graphical->selected to deal with the graphical<-area change resulting from displaying the control-points.

The control-points and dotted connection-lines are visible if the window<-selection_feedback is set to handles.

bezier_curve ->set_point: point=point, x=[int], y=[int]
Move (member) point to (X, Y). Depending on the point, this modifies bezier_curve<-start, bezier_curve<-control1, bezier_curve<-control2 or bezier_curve<-end and bezier_curve->compute’s the curve afterwards,

It is normally used with the result if bezier_curve<-point to allow interactive editing of bezier curves. See also the PceDraw demo application.

1.9.3 Get methods

bezier_curve <-point: near=point|event, max_distance=[int] -> point
Find closest point. This method is intended for editing and returns the closest of bezier_curve<-start, bezier_curve<-control1, bezier_curve<-control2 or bezier_curve<-end that is within max_distance.

This method is designed after path<-point. See also bezier_curve->set_point.