4.2 Text objects4 Object types4.1 Path objects

4.1 Path objects

Path objects are defined by a set of subpaths, that is, curves in the plane. Each subpath is either open or closed, and consists of straight line segments, circular or elliptic arc segments, parabola segments (or, equivalently, quadratic Bézier splines), cubic Bézier splines, and cubic B-spline segments. The curves are drawn with the stroke color, dash style, and line width; the interior of the object specified is filled using the fill color.

The distinction between open and closed subpaths is meaningful for stroking only, for filling any open subpath is implicitely closed. Stroking a set of subpaths is identical to stroking them individually. This is not true for filling: using several subpaths, one can construct objects with holes, and more complicated pattern. The filling algorithm is normally the even-odd rule of Postscript/PDF: To determine whether a point lies inside the filled shape, draw a ray from that point in any direction, and count the number of path segments that cross the ray. If this number is odd, the point is inside; if even, the point is outside.

Ipe can draw arrows on the first and last segment of a path object, but only if that segment is part of an open subpath.

There are several Ipe modes that create path objects in different ways. All modes create an object consisting of a single subpath only. To make more complicated path objects, such as objects with holes, you create each boundary component separately, then select them all and use the Compose paths function in the Edit menu. The reverse operation is Decompose path, you find it in the context menu of a path object that has several subpaths.

You can also create complicated paths by joining curves sequentially. For this to work, the endpoint of one path must be (nearly) identical to the begin point of the next—easy to achieve using snapping. You select the path objects you wish to join, and call Join paths in the Edit menu. You can also join several open path objects into a single closed path this way.

Circles can be entered in three different ways. To create an ellipse, create a circle and shear or stretch and rotate it. Circular arcs can be entered by clicking three points on the arc or by clicking the center of the supporting circle as well as the begin and end vertex of the arc. They can be filled in Postscript fashion, and can have arrows. You can stretch a circular arc to create an elliptic arc.

A common application for arcs is to mark angles in drawings. The snap keys are useful to create such arcs: set arc creation to center & 2 pts, select snap to vertex and snap to boundary, click first on the center point of the angle (which is magnetic) and click then on the two bounding lines.

There are two modes for creating more complex general path objects. The difference between line mode and polygon mode is that the first creates an open path, the latter generates a closed one. As a consequence, the line mode uses the current arrow settings, while the polygon mode doesn't. The path object created using line or polygon mode consists of segments of various types. The initial setting is to create straight segments. By holding the shift-key when pressing the left mouse button one can switch to uniform B-splines. One can also add quadratic Bézier spline segments, cubic Bézier spline segments, and circular arc segments as follows:

To add a quadratic Bézier spline (that is, a parabola), click twice in polyline mode for the first two control points. Then press the q key and click on the third (last) control point.

Similarly, to add a cubic Bézier spline, click three times in polyline mode on the first three control points. Press the c key, and click on the last control point.

Circular arcs can be added as follows: Click twice in polyline mode, once on the starting point of the arc, then on a point in the correct tangent direction. Press the a key, and click on the endpoint of the arc.

To make curves where segments of different type are joined with identical tangents, you can press the y key whenever you are starting a new segment: this will set the coordinate system centered at the starting point of the segment, and aligned with the tangent to the previous segment.

For the mathematically inclined, a more precise description of the segments that can appear on a subpath follows. More details can be found in Foley et al.2 and other text books on splines.

A subpath consists of a sequence of segments. Each segment is either a straight line segment, an elliptic arc, a quadratic Bézier spline, a cubic Bézier spline, or a uniform cubic B-spline.

The quadratic Bézier spline defined by control points p0, p1, and p2, is the curve

P(t) = (1-t)2 p0 + 2t(1-t) p1 + t2 p2,
where t ranges from 0 to 1. This implies that it starts in p0 tangent to the line p0p1, ends in p2 tangent to the line p1p2, and is contained in the convex hull of the three points. Any segment of any parabola can be expressed as a quadratic Bézier spline.

For instance, the piece of the unit parabola y = x2 between x=a and x=b can be created with the control points

p0 = (a, a2)
p1 = ( (a + b)/(2), ab)
p2 = (b, b2)
Any piece of any parabola can be created by applying some affine transformation to these points.

The cubic Bézier spline with control points p0, p1, p2, and p3 is the curve

R(t) = (1-t)3p0 + 3t(1-t)2 p1 + 3 t2(1-t) p2 + t3 p3.
It starts in p0 being tangent to the line p0p1, ends in p3 being tangent to the line p2p3, and lies in the convex hull of the four control points.

Uniform cubic B-splines approximate a series of m+1 control points p0, p1, …, pm, m ≥ 3, with a curve consisting of m-2 cubic polynomial curve segments s0, s1, …, sm-3. Every such curve segment is defined by four of the control points. In fact, curve segment si is defined by the points pi, pi+1, pi+2, and pi+3. If the curve is closed (a splinegon), it contains three additional curve segments sm-2, sm-1, and sm, defined by appending p0, p1, and p2 to the end of the sequence. A uniform B-spline segment on an open subpath of an Ipe path object is defined by repeating both the first and last control point three times, so as to make the segment begin and end in these points.

The segment si is the cubic curve segment with the following parametrization.

Q(t) = ((1-t)3)/(6) pi + (3t3 -6t2 + 4)/(6) pi+1 + (-3t3 + 3t2 + 3t +1)/(6) pi+2 + (t3)/(6) pi+3,
where t ranges from 0 to 1.

Since the point Q(t) is a convex combination of the four control points, the curve segment si lies in the convex hull of pi to pi+3. Furthermore, it follows that any affine transformation can be applied to the curve by applying it to the control points. Note that a control point pi has influence on only four curve segments, si-3, si-2, si-1, and si. Thus, when you edit a spline object and move a control point, only a short piece of the spline in the neighborhood of the control point will move.