Skip to content

POLYLINE ​

Draws a path of several joined lines.

Syntax ​

Syntax with a fixed amount of points:

leo-grammar
POLYLINE intValue
    [ x1:measureValue ] [ y1:measureValue ]
    [ x2:measureValue ] [ y2:measureValue ]
    ...
    [ xn:measureValue ] [ yn:measureValue ] .

Syntax using an array of points:

leo-grammar
POLYLINE arrayValue .

Parameters ​

Parameters for fixed amount of points:

  • <main-parameter> (intValue) - Used in the fixed amount of points version to specify the amount of points.
  • x<intValue> (measureValue, optional) - The x-coordinate of the n-th point where n-th is specified through <intValue>. The default is 0cm.
  • y<intValue> (measureValue, optional) - The y-coordinate of the n-th point where n-th is specified through <intValue>. The default is 0cm.

Parameters for array of points:

  • <main-parameter> (arrayValue) - Used in the array version to specify the points. The array must have an even amount of measure values.

Details ​

The style of this command is defined by the PEN command.

This command differs from [POLYGON] in that it only draws the line without connecting the last point back to the first.

When using the syntax with a fixed amount of points the coordinates are grouped by the number after x and y, like x1:... with y1:... and x2:... with y2:... etc. If more groups of points are provided than the amount of points stated in the main parameter, then excess coordinates are ignored.

When using the syntax with the array the amount of values in the array must be an equal number and all values must be a measureValue. The first two values are used as the x- and y-coordinate of the first point, the next two values as the x- and y-coordinate of the second point and so on.

The benefit of the array version is that it doesn't require to specify the amount of points upfront. Instead they are determined based on the array's length. This way other commands can be used to build the array dynamically.

See Also ​

Examples ​

Draw a simple diagonal line using a "fixed polyline".
Diagonal black line

leo
GRAPHREP
SHADOW off

POLYLINE 2
    x1:0cm y1:0cm
    x2:1.0cm y2:1.0cm

Draw a simple diagonal line using an array of points.
Diagonal black line

leo
GRAPHREP
SHADOW off

POLYLINE {0cm, 0cm, 1.0cm, 1.0cm}

Draw a "V" consisting of two dashed lines with a width of 2pt.
Two dashed lines creating a V

leo
GRAPHREP
SHADOW off

PEN style:dash w:2pt
POLYLINE 3
    x1:-0.5cm y1:-0.5cm
    x2:0cm y2:0.5cm
    x3:0.5cm y3:-0.5cm

Draw a dynamically calculated zig-zag pattern.
A triangular wavy line

leo
GRAPHREP
SHADOW off

# Configuration parameters.
SET dX:(0cm) dStartY:(0cm)
SET dW:(0.3cm) dH:(0.5cm)
SET nPoints:(7)
# Create array with a starting point.
SET aPattern:({dX, dStartY})
# `to` uses -2 because the first point has been added and the last point will be added later.
FOR nI from:(0) to:(nPoints - 2) {
  SET dX:(dX + cond(nI, dW, dW/2))
  SET dummy:(aappend(aPattern, dX))
  SET dummy:(aappend(aPattern, dStartY + cond(nI MOD 2, dH, -dH)))
}
# Addint the last point in the array.
SET dummy:(aappend(aPattern, dX + dW/2))
SET dummy:(aappend(aPattern, dStartY))

# Somewhere you have to draw the line.
POLYLINE (aPattern)

Versions and Changes ​

Available since ADOxx 1.3