Next: , Previous: , Up: Graphic Operations   [Contents][Index]

7.3 Drawing Lines

The draw-line, draw-lines, and draw-segments functions use the following graphics context components: background, cap-style, clip-x-origin, clip-y-origin, clip-mask, dash-list, dash-offset, fill-style, foreground, function, plane-mask, line-width, line-style, stipple, subwindow-mode, tile, ts-x-origin, and ts-y-origin.

The draw-lines function also uses the join-style graphics context component.

Function: draw-line drawable gcontext x1 y1 x2 y2 &optional relative-p

The destination drawable.


The graphics context for drawing the line.


The end points of the line.


Specifies the coordinate mode used for drawing the line either relative to the origin or the previous point. In either case, the first point is always drawn relative to the drawable’s origin.

Draws a line from the point x1,y1 to the point x2,y2. When relative-p is true, the first point is relative to the destination origin but the second point is relative to the first point. When relative-p is nil, both points are relative to the destination origin.

Function: draw-lines drawable gcontext points &key :relative-p :fill-p (:shape :complex)

The destination drawable.


The graphics context for drawing the lines.


A list of points that define the lines. Type is point-seq.


The coordinate mode of the points.


When true, a filled polygon is drawn instead of a polyline.


A hint that allows the server to use the most efficient area fill algorithm. Either :convex, :non-convex, or :complex.

Draws a line between each pair of points in the points list. The lines are drawn in the order listed and join correctly at all intermediate points. The join-style graphics context component defines the type of joint to use. When the first and last points coincide, the first and last lines also join correctly to produce a hollow polygon.

When :relative-p is true, the first point is always relative to the destination origin, but the rest are relative to the previous point. When :relative-p is nil, the rest of the points are drawn relative to the destination origin.

When :fill-p is true, the polygon defined by the points list is filled. The :shape keyword provides the server with a hint about how to fill the polygon. :shape can be either :complex (by default), :convex, or :non-convex.

The :convex operand is the simplest type of area and the fastest to fill. A fill area is convex if every straight line connecting any two interior points is entirely inside the area. For example, triangles and rectangles are convex polygons.

The :non-convex operand is for filling an area that is not convex and is also not self-intersecting. Filling this type of area is harder than filling a convex area, but easier than filling one that is self-intersecting. For example, the shape of the letter "T" is non-convex and non-self-intersecting.

The :complex operand is the most general (and therefore the hardest) type of fill area. A complex fill area can be non-convex and self-intersecting. For example, draw the outline of a bow tie, without lifting your pencil or tracing over an edge twice. This shape is non-convex and intersects itself at the knot in the middle.

NOTE: Unless you are sure that a shape is :convex or :non-convex, it should always be drawn as a :complex shape. If :convex or :non-convex is specified incorrectly, the graphics result is undefined.

Function: draw-segments drawable gcontext segments

The destination drawable to receive the line segments.


Specifies the graphics context for drawing the lines.


The points list for the segments to draw. Type is seq.

Draws multiple lines, not necessarily connected. segments is a sequence of the form {x1 y1 x2 y2}*, in which each subsequence specifies the end points of a line segment. Line segments are drawn in the order given by segments. Unlike draw-lines, no joining is performed at coincident end points.

Next: , Previous: , Up: Graphic Operations   [Contents][Index]