Next: gEDA File Format Document Revision History, Previous: Embedded Components, Up: gEDA file format [Contents][Index]

### 12.8 Path data

The gEDA/gaf path data format has been deliberately specified to match a subset of that in the W3C SVG standard..

- As an implementation detail; libgeda takes code from librsvg, an SVG parsing library. As a result, the majority of SVG path syntax is read correctly, however this is always normalised to absolute move, line, Bézier curve and close-path commands internally (and is saved as such).
- Coordinates along the path are specified in the standard gschem coordinate space.
- Those path commands which gEDA emits, and will guarantee to parse, are listed in the table below:

  (Text taken from the above SVG specification).

- In the table below, the following notation is used:
  - (): grouping of parameters
  - +: 1 or more of the given parameter(s) is required

Command | Name | Parameters | Description
M (absolute) | moveto | (x,y)+ | Start a new sub-path at the given (x,y) coordinate. M (uppercase) indicates that absolute coordinates will follow; m (lowercase) indicates that relative coordinates will follow. If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates. If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands.
L (absolute) | lineto | (x,y)+ | Draw a line from the current point to the given (x,y) coordinate which becomes the new current point. L (uppercase) indicates that absolute coordinates will follow; l (lowercase) indicates that relative coordinates will follow. A number of coordinates pairs may be specified to draw a polyline. At the end of the command, the new current point is set to the final set of coordinates provided.
C (absolute) | curveto | (x1,y1 x2,y2 x,y)+ | Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. C (uppercase) indicates that absolute coordinates will follow; c (lowercase) indicates that relative coordinates will follow. Multiple sets of coordinates may be specified to draw a polybézier. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybézier.
Z or z | closepath | (none) | Close the current subpath by drawing a straight line from the current point to current subpath’s initial point.

- gEDA’s output currently emits only the absolute coordinate versions of the above commands.
- gEDA’s output currently emits the commands, M, L, C before every set of coordinates, even where they could be omitted according to the SVG specification.
- gEDA’s output places commas between x,y coordinates. These may be replaced with whitespace according to the SVG specification.
- gEDA’s does not currently support more than one sub-path.
- gEDA currently emits one path data line per command + coordinate set.

As example, lets draw the outline of an AND gate. The path data is:

    M 100,100 L 500,100 C 700,100 800,275 800,400
    C 800,525 700,700 500,700 L 100,700 z

And a complete schematic:

    v 20080706 1
    H 3 0 0 0 -1 -1 0 2 20 100 -1 -1 6
    M 100,100
    L 500,100
    C 700,100 800,275 800,400
    C 800,525 700,700 500,700
    L 100,700
    z

The resulting path (with control points drawn on to illustrate their positions) is shown here:

Next: gEDA File Format Document Revision History, Previous: Embedded Components, Up: gEDA file format [Contents][Index]