Next: , Previous: , Up: Core object functions   [Contents][Index]


2.2.8 Paths

Paths are arbitrary shapes comprised of straight lines and Bézier curves. Each path contains a sequence of path elements, each of which requires zero or more absolute position parameters. The element types supported by Lepton are:

Function: path? object

Returns ‘#t’ if and only if object is a path object.

Function: make-path [color]

Creates and returns a new path object. If color is specified, it should be the integer color map index of the color with which to draw the path. If color is not specified, the default path color is used.

Function: path-length path

Returns the number of path elements in path.

Function: path-ref path K

Returns the Kth element in path. The return value is a list. The first item in the list is a symbol indicating the type of element, and any additional items are the position parameters of the element. For example, a call to path-ref might return:

(curveto (800 . 525) (700 . 700) (500 . 700))

If K is not a valid offset into path, raises an ‘out-of-range’ error.

Function: path-remove! path K

Removes the Kth element in path, returning path. If K is not a valid offset, raises an ‘out-of-range’ error.

Function: path-insert! path K type [positions...]

Inserts a new element into path at index K. type is a symbol indicating the type of element to insert, using the parameters positions. If K is less than zero or greater than the number of elements path already contains, the new element is appended to the path. For example, to append a straight line section to the current path:

(path-insert! path -1 'lineto '(500 . 100))

Next: Pictures, Previous: Arcs, Up: Core object functions   [Contents][Index]