class HexaPDF::Content::LineDashPattern

Parent

The line dash pattern defines how a line should be dashed. For use with e.g. Canvas#line_dash_pattern.

A dash pattern consists of two parts: the dash array and the dash phase. The dash array defines the length of alternating dashes and gaps (important: starting with dashes). And the dash phase defines the distance into the dash array at which to start.

It is easier to show. Following are dash arrays and dash phases and how they would be interpreted:

[] 0                      No dash, one solid line
[3] 0                     3 unit dash, 3 unit gap, 3 unit dash, 3 unit gap, ...
[3] 1                     2 unit dash, 3 unit gap, 3 unit dash, 3 unit gap, ...
[2 1] 0                   2 unit dash, 1 unit gap, 2 unit dash, 1 unit gap, ...
[3 5] 6                   2 unit gap, 3 unit dash, 5 unit gap, 3 unit dash, ...
[2 3] 6                   1 unit dash, 3 unit gap, 2 unit dash, 3 unit gap, ...

And visualized it looks like this:

See: PDF2.0 s8.4.3.6

Attributes

array[R]

The dash array.

phase[R]

The dash phase.

Public Class Methods

new(array = [], phase = 0)

Inititalizes the line dash pattern with the given array and phase.

The argument phase must be non-negative and the numbers in the array must be non-negative and must not all be zero.

normalize(line_dash_pattern) → line_dash_pattern
normalize(array, phase = 0) → LineDashPattern.new(array, phase)
normalize(number, phase = 0) → LineDashPattern.new([number], phase)
normalize(0) → LineDashPattern.new

Returns the arguments normalized to a valid LineDashPattern instance.

If array is 0, the default line dash pattern representing a solid line will be used. If it is a single number, it will be converted into an array holding that number.

Public Instance Methods

==(other)

Returns true if the other line dash pattern is the same as this one.

to_operands()

Converts the LineDashPattern object to an array of operands for the associated PDF content operator.