Usually the application programmer does not have to use segments directly when defining a shape. Instead there are a few operations in the shape that can be perceived as a language for shape definition: Open, Close, LineTo, SplineTo, Stroke, in addition to several operations for combining shapes. Combining shapes is not a straightforward task and is the subject of a subsequent section.
When using these operations, the concept of shape control points is used instead of segment control points. When looking at control points of the shape, the two control points in a joining of two segments are seen as one control point of the shape.
The first four operations for shape definition are used for adding control points to the shape. Depending on which operation is used, the curve between the previously placed control point and the new control point can be either a line or a non-circular spline. The Stroke operations is a powerful way of defining shapes illustrating outlines of graphical objects. It will be presented in the next section.
The following example illustrates the use of the LineTo and Close operations:
|
Resulting triangle:
|
The triangle shape now consists of three line segments, is closed and could be used in a graphical object.
Two different cases must be considered: is there currently a
non-circular spline under construction or not.
In the former case (the last operation was SplineTo) the specified
point is just added as a spline control point to that spline segment.
In the latter case (the last operations was LineTo or Open) a spline segment will be created with the ending point of the shape as the first spline control point and the specified point as the second spline control point. The following example illustrates the use of SplineTo:
|
Resulting open shape:
|
If a LineTo message follows a spline construction, LastPoint of the spline segment becomes FirstPoint of the new line segment. The shape in the example above consists of two line segments and one spline segments with three control points. Notice that the shape is not closed.
If a Close message follows a spline construction, the spline will be ended with a control point in the starting point of the shape:
|
Resulting closed shape:
|
MyShape consists of two segments, one line segment and one spline segment with five control points. Circular splines can not be constructed with the SplineTo primitive. Circular splines have to be created as circular spline segments and then added to the shape.
The Bifrost Graphics System - Reference Manual | © 1991-2004 Mjølner Informatics |
[Modified: Tuesday October 24th 2000 at 15:02]
|