Module: Prawn::Graphics::Dash
- Included in:
- Prawn::Graphics
- Defined in:
- lib/prawn/graphics/dash.rb
Overview
Implements stroke dashing.
Stable API collapse
-
#dash(length = nil, options = {}) ⇒ Object
(also: #dash=)
Get or set stroke dash pattern.
-
#dashed? ⇒ Boolean
Returns ‘true` when stroke is dashed, `false` otherwise.
-
#undash ⇒ void
Stops dashing, restoring solid stroked lines and curves.
Instance Method Details
#dash ⇒ Hash{:dash => Number, Array<Number>, :space => Number, nil, :phase => Number} #dash(length, options = {}) ⇒ void Also known as: dash=
Get or set stroke dash pattern.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/prawn/graphics/dash.rb', line 59 def dash(length = nil, = {}) return current_dash_state if length.nil? length = Array(length) if length.all?(&:zero?) raise ArgumentError, 'Zero length dashes are invalid. Call #undash to disable dashes.' elsif length.any?(&:negative?) raise ArgumentError, 'Negative numbers are not allowed for dash lengths.' end length = length.first if length.length == 1 self.current_dash_state = { dash: length, space: length.is_a?(Array) ? nil : [:space] || length, phase: [:phase] || 0, } write_stroke_dash end |
#dashed? ⇒ Boolean
Returns ‘true` when stroke is dashed, `false` otherwise.
96 97 98 |
# File 'lib/prawn/graphics/dash.rb', line 96 def dashed? current_dash_state != undashed_setting end |
#undash ⇒ void
This method returns an undefined value.
Stops dashing, restoring solid stroked lines and curves.
88 89 90 91 |
# File 'lib/prawn/graphics/dash.rb', line 88 def undash self.current_dash_state = undashed_setting write_stroke_dash end |