Lines

Rayon line objects encode information about where and how line segments should be drawn. They are used throughout Rayon, notably in borders, grid lines and plots.

Lines are created using the new_line method.

Lines and antialiasing

The rendering backends Rayon uses generally perform antialiasing on images to remove distracting artifacts. This results in smooth diagonal lines, corners and curves.

When drawing straight vertical and horizontal lines, however, antialiasing can cause a lines edges to be blurred. This can sometimes be avoided (e.g., by aligning the edges of the line exactly on a pixel boundary).

If the fixup parameter is specified in the new_line method and the line is perfectly horizontal or vertical, Rayon will attempt to adjust the line’s position to avoid anti-aliasing. Note, however, that this may introduce problems of its own, for instance by introducing gaps between objects that should be contiguous.

Creating lines

Lines can be created using one of two methods on the Toolbox object. The first is the new_line method, which creates a line from a label and set of arguments, similarly to most methods in the toolbox.

Alternatively, the new_line_from_spec method takes a string line specification (see Specifying Line Styles) and uses that to create a line. The string specification method is useful for programs which create lines based on user input.

dashed

toolbox.new_line('dashed'[, color="#000000FF", width=1, fixup=False])

Renders a dashed line.

color is the color of the line.

width is the width of the line in pixels/points.

If fixup is True, Rayon will attempt to “fix up” perfectly horizontal and vertical lines to avoid anti-aliasing. This behavior is disabled if fixup is False.

dotted

toolbox.new_line('dotted'[, color="#000000FF", width=1, fixup=False])

Renders a dotted line.

color is the color of the line.

width is the width of the line in pixels/points.

If fixup is True, Rayon will attempt to “fix up” perfectly horizontal and vertical lines to avoid anti-aliasing. This behavior is disabled if fixup is False.

dotdash

toolbox.new_line('dotdash'[, color="#000000FF", width=1, fixup=False])

Renders a line that is a mixture of dots and dashes.

color is the color of the line.

width is the width of the line in pixels/points.

If fixup is True, Rayon will attempt to “fix up” perfectly horizontal and vertical lines to avoid anti-aliasing. This behavior is disabled if fixup is False.

none

toolbox.new_line('null'[, color="#000000FF", width=1, fixup=False])

Can be used like a line, but doesn’t actually draw a line. All arguments to

solid

toolbox.new_line('solid'[, color="#000000FF", width=1, fixup=False])