Overview of Item Types

Spline Items

Items of type spline appear on the display as one or more bezier curves joined end to end, so the last point of the one curve is used as the first point of the next. Splines are displayed as smooth curves at any magnification. They are rendered in more detail when they are larger. It is possible to create a fixed approximation to a spline with the spline2line command. In addition, it is possible to generate a spline that approximates a multi-segmented line with the line2spline command. A bezier curve is defined using four points - the start and end point for the curve, and two control points that indicate the path that the curve follows. For example:

For a spline made from a single bezier segment, the points are given as follows:

<start-x> <start-y> <c1-x> <c1-y> <c2-x> <c2-y> <end-x> <end-y>

That is, first the start point is given, followed by the first control point, followed by the second control point and finishing with the end point for the curve. For example, you can create a simple spline using:

.pad create spline 0 0 10 10 20 10 30 0

here (0, 0) defines the start of the curve. (10, 10) is the first control point, (20, 10) is the second control point, and the curve ends at (30, 0).

Splines are created with widget commands of the following form:

pathName create spline x1 y1... xn yn [option value option value ...]

The arguments x1 through yn give the coordinates for a series of one or more splines. Each point is specified by two coordinates. When specifying a spline made from two or more bezier curves, the end point of the first curve is used as the start point for the second, so the second curve only requires an additional three points (two control points and an end point). In general a spline of N bezier curves requires 3N+1 points (6N+2 coordinates). This represents a start point and then three points for each curve.

For convenience, if the end point of the last curve segment in a spline is omitted, Pad++ assumes that the curve should be 'closed' - it uses the start point of the first curve as the end point for the last curve, creating a closed shape. For closed shapes, therefore, you should provide 3N points (6N coordinates).

After the coordinates there may be any number of option-value pairs, each of which sets one of the configuration options for the item. These same option-value pairs may be used in itemconfigure widget commands to change the item's configuration. The following options are supported for lines:


[77] -arrowshape shape

(available only for line and spline item types)

This option indicates how to draw arrowheads. The shape argument must be a list with three elements, each specifying a distance. The first element of the list gives the distance along the spline from the neck of the arrowhead to its tip. The second element gives the distance along the spline from the trailing points of the arrowhead to the tip, and the third element gives the distance from the outside edge of the spline to the trailing points. If this option isn't specified then Pad++ picks a "reasonable" shape.


[78] -arrow where

(available only for line and spline item types)


Indicates whether or not arrowheads are to be drawn at one or both ends of the spline. where must have one of the values "none" (for no arrowheads), "first" (for an arrowhead at the first point of the line), "last" (for an arrowhead at the last point of the line), or "both" (for arrowheads at both ends). This option defaults to "none".


[79] -capstyle cap

(available only for line and spline item types)


Specifies how the ends of the spline are drawn. cap may be one of:

[80] -joinstyle join

(available only for line, polygon, rectangle and spline item types)

Specifies how the joints at vertices are drawn. join may be one of:

[81] -pen color

(available only for handle, line, polygon, portal, rectangle, spline, text and textfile item types)

Color specifies a color to use for drawing the spline; it may have any of the forms acceptable to Tk_GetColor. It may also be "none", in which case the line will not be drawn. This option defaults to black.

[82] -penwidth width

(available only for line, ploygon, rectangle and spline item types)


Width specifies the width of the pen in current units to be drawn around the item. Wide lines will be drawn centered on the path specified by the points. If width is 0.0, then the pen will always be drawn one pixel wide, independent of the zoom. Width defaults to 1 pixel.


July 9, 1996 - 9 JUL 1996

Generated with Harlequin WebMaker

Web Accessibility