giga-fast-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/giga-fast-kit.gemspec +12 -0
- data/prawn-2.5.0/COPYING +2 -0
- data/prawn-2.5.0/GPLv2 +339 -0
- data/prawn-2.5.0/GPLv3 +674 -0
- data/prawn-2.5.0/LICENSE +56 -0
- data/prawn-2.5.0/data/fonts/Courier-Bold.afm +342 -0
- data/prawn-2.5.0/data/fonts/Courier-BoldOblique.afm +342 -0
- data/prawn-2.5.0/data/fonts/Courier-Oblique.afm +342 -0
- data/prawn-2.5.0/data/fonts/Courier.afm +342 -0
- data/prawn-2.5.0/data/fonts/Helvetica-Bold.afm +2827 -0
- data/prawn-2.5.0/data/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/prawn-2.5.0/data/fonts/Helvetica-Oblique.afm +3051 -0
- data/prawn-2.5.0/data/fonts/Helvetica.afm +3051 -0
- data/prawn-2.5.0/data/fonts/MustRead.html +19 -0
- data/prawn-2.5.0/data/fonts/Symbol.afm +213 -0
- data/prawn-2.5.0/data/fonts/Times-Bold.afm +2588 -0
- data/prawn-2.5.0/data/fonts/Times-BoldItalic.afm +2384 -0
- data/prawn-2.5.0/data/fonts/Times-Italic.afm +2667 -0
- data/prawn-2.5.0/data/fonts/Times-Roman.afm +2419 -0
- data/prawn-2.5.0/data/fonts/ZapfDingbats.afm +225 -0
- data/prawn-2.5.0/lib/prawn/document/bounding_box.rb +625 -0
- data/prawn-2.5.0/lib/prawn/document/column_box.rb +177 -0
- data/prawn-2.5.0/lib/prawn/document/internals.rb +76 -0
- data/prawn-2.5.0/lib/prawn/document/span.rb +65 -0
- data/prawn-2.5.0/lib/prawn/document.rb +846 -0
- data/prawn-2.5.0/lib/prawn/encoding.rb +85 -0
- data/prawn-2.5.0/lib/prawn/errors.rb +73 -0
- data/prawn-2.5.0/lib/prawn/font.rb +567 -0
- data/prawn-2.5.0/lib/prawn/font_metric_cache.rb +50 -0
- data/prawn-2.5.0/lib/prawn/fonts/afm.rb +332 -0
- data/prawn-2.5.0/lib/prawn/fonts/dfont.rb +42 -0
- data/prawn-2.5.0/lib/prawn/fonts/otf.rb +14 -0
- data/prawn-2.5.0/lib/prawn/fonts/to_unicode_cmap.rb +151 -0
- data/prawn-2.5.0/lib/prawn/fonts/ttc.rb +41 -0
- data/prawn-2.5.0/lib/prawn/fonts/ttf.rb +615 -0
- data/prawn-2.5.0/lib/prawn/fonts.rb +14 -0
- data/prawn-2.5.0/lib/prawn/graphics/blend_mode.rb +62 -0
- data/prawn-2.5.0/lib/prawn/graphics/cap_style.rb +44 -0
- data/prawn-2.5.0/lib/prawn/graphics/color.rb +257 -0
- data/prawn-2.5.0/lib/prawn/graphics/dash.rb +123 -0
- data/prawn-2.5.0/lib/prawn/graphics/join_style.rb +60 -0
- data/prawn-2.5.0/lib/prawn/graphics/patterns.rb +389 -0
- data/prawn-2.5.0/lib/prawn/graphics/transformation.rb +172 -0
- data/prawn-2.5.0/lib/prawn/graphics/transparency.rb +79 -0
- data/prawn-2.5.0/lib/prawn/graphics.rb +791 -0
- data/prawn-2.5.0/lib/prawn/grid.rb +449 -0
- data/prawn-2.5.0/lib/prawn/image_handler.rb +61 -0
- data/prawn-2.5.0/lib/prawn/images/image.rb +48 -0
- data/prawn-2.5.0/lib/prawn/images/jpg.rb +121 -0
- data/prawn-2.5.0/lib/prawn/images/png.rb +383 -0
- data/prawn-2.5.0/lib/prawn/images.rb +195 -0
- data/prawn-2.5.0/lib/prawn/measurement_extensions.rb +82 -0
- data/prawn-2.5.0/lib/prawn/measurements.rb +129 -0
- data/prawn-2.5.0/lib/prawn/outline.rb +316 -0
- data/prawn-2.5.0/lib/prawn/repeater.rb +140 -0
- data/prawn-2.5.0/lib/prawn/security/arcfour.rb +54 -0
- data/prawn-2.5.0/lib/prawn/security.rb +308 -0
- data/prawn-2.5.0/lib/prawn/soft_mask.rb +105 -0
- data/prawn-2.5.0/lib/prawn/stamp.rb +147 -0
- data/prawn-2.5.0/lib/prawn/text/box.rb +192 -0
- data/prawn-2.5.0/lib/prawn/text/formatted/arranger.rb +396 -0
- data/prawn-2.5.0/lib/prawn/text/formatted/box.rb +725 -0
- data/prawn-2.5.0/lib/prawn/text/formatted/fragment.rb +373 -0
- data/prawn-2.5.0/lib/prawn/text/formatted/line_wrap.rb +335 -0
- data/prawn-2.5.0/lib/prawn/text/formatted/parser.rb +284 -0
- data/prawn-2.5.0/lib/prawn/text/formatted/wrap.rb +166 -0
- data/prawn-2.5.0/lib/prawn/text/formatted.rb +82 -0
- data/prawn-2.5.0/lib/prawn/text.rb +701 -0
- data/prawn-2.5.0/lib/prawn/transformation_stack.rb +63 -0
- data/prawn-2.5.0/lib/prawn/utilities.rb +34 -0
- data/prawn-2.5.0/lib/prawn/version.rb +6 -0
- data/prawn-2.5.0/lib/prawn/view.rb +116 -0
- data/prawn-2.5.0/lib/prawn.rb +83 -0
- metadata +114 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Prawn
|
|
4
|
+
module Graphics
|
|
5
|
+
# Implements stroke cap styling
|
|
6
|
+
module CapStyle
|
|
7
|
+
# @group Stable API
|
|
8
|
+
|
|
9
|
+
# @private
|
|
10
|
+
CAP_STYLES = { butt: 0, round: 1, projecting_square: 2 }.freeze
|
|
11
|
+
|
|
12
|
+
# Sets the cap style for stroked lines and curves.
|
|
13
|
+
#
|
|
14
|
+
# @overload cap_style(style)
|
|
15
|
+
# @param style [:butt, :round, :projecting_square] (:butt)
|
|
16
|
+
# @return [void]
|
|
17
|
+
# @overload cap_style()
|
|
18
|
+
# @return [Symbol]
|
|
19
|
+
def cap_style(style = nil)
|
|
20
|
+
return current_cap_style || :butt if style.nil?
|
|
21
|
+
|
|
22
|
+
self.current_cap_style = style
|
|
23
|
+
|
|
24
|
+
write_stroke_cap_style
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
alias cap_style= cap_style
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def current_cap_style
|
|
32
|
+
graphic_state.cap_style
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def current_cap_style=(style)
|
|
36
|
+
graphic_state.cap_style = style
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def write_stroke_cap_style
|
|
40
|
+
renderer.add_content("#{CAP_STYLES[current_cap_style]} J")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Prawn
|
|
4
|
+
module Graphics
|
|
5
|
+
# Implements color handling.
|
|
6
|
+
module Color
|
|
7
|
+
# @group Stable API
|
|
8
|
+
|
|
9
|
+
# Sets or returns the fill color.
|
|
10
|
+
#
|
|
11
|
+
# @overload fill_color
|
|
12
|
+
# Returns the current fill color.
|
|
13
|
+
#
|
|
14
|
+
# @return [String, Array<Number>]
|
|
15
|
+
#
|
|
16
|
+
# @overload fill_color(color)
|
|
17
|
+
# Sets the fill color.
|
|
18
|
+
#
|
|
19
|
+
# If a single argument is provided, it should be a 6 digit HTML color
|
|
20
|
+
# code.
|
|
21
|
+
#
|
|
22
|
+
# ```ruby
|
|
23
|
+
# pdf.fill_color "f0ffc1"
|
|
24
|
+
# ```
|
|
25
|
+
#
|
|
26
|
+
# If 4 arguments are provided, the color is assumed to be a CMYK value.
|
|
27
|
+
# Values range is 0–100.
|
|
28
|
+
#
|
|
29
|
+
# ```ruby
|
|
30
|
+
# pdf.fill_color 0, 99, 95, 0
|
|
31
|
+
# ```
|
|
32
|
+
#
|
|
33
|
+
# @param color [String, Array<Number>]
|
|
34
|
+
# @return [void]
|
|
35
|
+
def fill_color(*color)
|
|
36
|
+
return current_fill_color if color.empty?
|
|
37
|
+
|
|
38
|
+
self.current_fill_color = process_color(*color)
|
|
39
|
+
set_fill_color
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias fill_color= fill_color
|
|
43
|
+
|
|
44
|
+
# Sets or returns the line stroking color.
|
|
45
|
+
#
|
|
46
|
+
# @overload stroke_color
|
|
47
|
+
# When called with no argument, it returns the current stroking color.
|
|
48
|
+
#
|
|
49
|
+
# @return [String, Array<Number>]
|
|
50
|
+
#
|
|
51
|
+
# @overload stroke_color(color)
|
|
52
|
+
# Sets the stroking color.
|
|
53
|
+
#
|
|
54
|
+
# @param color [String, Array<Number>] new stroking color:
|
|
55
|
+
# - In String form it should be a 6 digit HTML color code.
|
|
56
|
+
#
|
|
57
|
+
# ```ruby
|
|
58
|
+
# pdf.stroke_color "f0ffc1"
|
|
59
|
+
# ```
|
|
60
|
+
# - If 4 arguments are provided, the color is assumed to be a CMYK
|
|
61
|
+
# value. Values range from 0 to 100.
|
|
62
|
+
#
|
|
63
|
+
# ```ruby
|
|
64
|
+
# pdf.stroke_color 0, 99, 95, 0
|
|
65
|
+
# ```
|
|
66
|
+
# @return [void]
|
|
67
|
+
def stroke_color(*color)
|
|
68
|
+
return current_stroke_color if color.empty?
|
|
69
|
+
|
|
70
|
+
color = process_color(*color)
|
|
71
|
+
self.current_stroke_color = color
|
|
72
|
+
set_stroke_color(color)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
alias stroke_color= stroke_color
|
|
76
|
+
|
|
77
|
+
module_function
|
|
78
|
+
|
|
79
|
+
# Converts RGB value array to hex string suitable for use with
|
|
80
|
+
# {fill_color} and {stroke_color}.
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# Prawn::Graphics::Color.rgb2hex([255, 120, 8])
|
|
84
|
+
# #=> "ff7808"
|
|
85
|
+
#
|
|
86
|
+
# @param rgb [Array(Number, Number, Number)]
|
|
87
|
+
# Each component has to be in the range from 0 to 255.
|
|
88
|
+
# @return [String]
|
|
89
|
+
def rgb2hex(rgb)
|
|
90
|
+
rgb.map { |e| format('%<value>02x', value: e) }.join
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Converts hex string into RGB value array.
|
|
94
|
+
#
|
|
95
|
+
# @example
|
|
96
|
+
# Prawn::Graphics::Color.hex2rgb("ff7808")
|
|
97
|
+
# #=> [255, 120, 8]
|
|
98
|
+
#
|
|
99
|
+
# @param hex [String] must be 6-digits long.
|
|
100
|
+
# @return [Array(Integer, Integer, Integer)]
|
|
101
|
+
def hex2rgb(hex)
|
|
102
|
+
r = hex[0..1]
|
|
103
|
+
g = hex[2..3]
|
|
104
|
+
b = hex[4..5]
|
|
105
|
+
[r, g, b].map { |e| e.to_i(16) }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def process_color(*color)
|
|
111
|
+
case color.size
|
|
112
|
+
when 1
|
|
113
|
+
color[0]
|
|
114
|
+
when 4
|
|
115
|
+
color
|
|
116
|
+
else
|
|
117
|
+
raise ArgumentError, 'wrong number of arguments supplied'
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def color_type(color)
|
|
122
|
+
case color
|
|
123
|
+
when String
|
|
124
|
+
if /\A\h{6}\z/.match?(color)
|
|
125
|
+
:RGB
|
|
126
|
+
else
|
|
127
|
+
raise ArgumentError, "Unknown type of color: #{color.inspect}"
|
|
128
|
+
end
|
|
129
|
+
when Array
|
|
130
|
+
case color.length
|
|
131
|
+
when 3
|
|
132
|
+
:RGB
|
|
133
|
+
when 4
|
|
134
|
+
:CMYK
|
|
135
|
+
else
|
|
136
|
+
raise ArgumentError, "Unknown type of color: #{color.inspect}"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def normalize_color(color)
|
|
142
|
+
case color_type(color)
|
|
143
|
+
when :RGB
|
|
144
|
+
r, g, b = hex2rgb(color)
|
|
145
|
+
[r / 255.0, g / 255.0, b / 255.0]
|
|
146
|
+
when :CMYK
|
|
147
|
+
c, m, y, k = *color
|
|
148
|
+
[c / 100.0, m / 100.0, y / 100.0, k / 100.0]
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def color_to_s(color)
|
|
153
|
+
PDF::Core.real_params(normalize_color(color))
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def color_space(color)
|
|
157
|
+
case color_type(color)
|
|
158
|
+
when :RGB
|
|
159
|
+
:DeviceRGB
|
|
160
|
+
when :CMYK
|
|
161
|
+
:DeviceCMYK
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
COLOR_SPACES = %i[DeviceRGB DeviceCMYK Pattern].freeze
|
|
166
|
+
|
|
167
|
+
def set_color_space(type, color_space)
|
|
168
|
+
# don't set the same color space again
|
|
169
|
+
if current_color_space(type) == color_space &&
|
|
170
|
+
!state.page.in_stamp_stream?
|
|
171
|
+
return
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
set_current_color_space(color_space, type)
|
|
175
|
+
|
|
176
|
+
unless COLOR_SPACES.include?(color_space)
|
|
177
|
+
raise ArgumentError, "unknown color space: '#{color_space}'"
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
operator =
|
|
181
|
+
case type
|
|
182
|
+
when :fill
|
|
183
|
+
'cs'
|
|
184
|
+
when :stroke
|
|
185
|
+
'CS'
|
|
186
|
+
else
|
|
187
|
+
raise ArgumentError, "unknown type '#{type}'"
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
renderer.add_content("/#{color_space} #{operator}")
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def set_color(type, color, options = {})
|
|
194
|
+
operator =
|
|
195
|
+
case type
|
|
196
|
+
when :fill
|
|
197
|
+
'scn'
|
|
198
|
+
when :stroke
|
|
199
|
+
'SCN'
|
|
200
|
+
else
|
|
201
|
+
raise ArgumentError, "unknown type '#{type}'"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
if options[:pattern]
|
|
205
|
+
set_color_space(type, :Pattern)
|
|
206
|
+
renderer.add_content("/#{color} #{operator}")
|
|
207
|
+
else
|
|
208
|
+
set_color_space(type, color_space(color))
|
|
209
|
+
color = color_to_s(color)
|
|
210
|
+
write_color(color, operator)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def set_fill_color(color = nil)
|
|
215
|
+
set_color(:fill, color || current_fill_color)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def set_stroke_color(color = nil)
|
|
219
|
+
set_color(:stroke, color || current_stroke_color)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def update_colors
|
|
223
|
+
set_fill_color
|
|
224
|
+
set_stroke_color
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def current_color_space(type)
|
|
228
|
+
graphic_state.color_space[type]
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def set_current_color_space(color_space, type)
|
|
232
|
+
save_graphics_state if graphic_state.nil?
|
|
233
|
+
graphic_state.color_space[type] = color_space
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def current_fill_color
|
|
237
|
+
graphic_state.fill_color
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def current_fill_color=(color)
|
|
241
|
+
graphic_state.fill_color = color
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def current_stroke_color
|
|
245
|
+
graphic_state.stroke_color
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def current_stroke_color=(color)
|
|
249
|
+
graphic_state.stroke_color = color
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def write_color(color, operator)
|
|
253
|
+
renderer.add_content("#{color} #{operator}")
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Prawn
|
|
4
|
+
module Graphics
|
|
5
|
+
# Implements stroke dashing.
|
|
6
|
+
module Dash
|
|
7
|
+
# @group Stable API
|
|
8
|
+
|
|
9
|
+
# Get or set stroke dash pattern.
|
|
10
|
+
#
|
|
11
|
+
# @overload dash()
|
|
12
|
+
# Returns the current dash pattern.
|
|
13
|
+
#
|
|
14
|
+
# @return [Hash{:dash => Number, Array<Number>, :space => Number, nil, :phase => Number}]
|
|
15
|
+
#
|
|
16
|
+
# @overload dash(length, options ={})
|
|
17
|
+
# Sets the dash pattern for stroked lines and curves.
|
|
18
|
+
#
|
|
19
|
+
# Integers or Floats may be used for length and the option values.
|
|
20
|
+
# Dash units are in PDF points (1/72 inch).
|
|
21
|
+
#
|
|
22
|
+
# @param length [Number, Array<Number>]
|
|
23
|
+
# * If `length` is a Number (Integer or Float), it specifies the
|
|
24
|
+
# length of the dash and of the gap. The length of the gap can be
|
|
25
|
+
# customized by setting the `:space` option.
|
|
26
|
+
#
|
|
27
|
+
# Examples:
|
|
28
|
+
#
|
|
29
|
+
# length = 3
|
|
30
|
+
# : 3 on, 3 off, 3 on, 3 off, ...
|
|
31
|
+
#
|
|
32
|
+
# length = 3, :space = 2
|
|
33
|
+
# : 3 on, 2 off, 3 on, 2 off, ...
|
|
34
|
+
#
|
|
35
|
+
# * If `length` is an array, it specifies the lengths of alternating
|
|
36
|
+
# dashes and gaps. The numbers must be non-negative and not all
|
|
37
|
+
# zero. The `:space` option is ignored in this case.
|
|
38
|
+
#
|
|
39
|
+
# Examples:
|
|
40
|
+
#
|
|
41
|
+
# length = [2, 1]
|
|
42
|
+
# : 2 on, 1 off, 2 on, 1 off, ...
|
|
43
|
+
#
|
|
44
|
+
# length = [3, 1, 2, 3]
|
|
45
|
+
# : 3 on, 1 off, 2 on, 3 off, 3 on, 1 off, ...
|
|
46
|
+
#
|
|
47
|
+
# length = [3, 0, 1]
|
|
48
|
+
# : 3 on, 0 off, 1 on, 3 off, 0 on, 1 off, ...
|
|
49
|
+
# @param options [Hash{Symbol => any}]
|
|
50
|
+
# @option options :space [Number]
|
|
51
|
+
# The space between the dashes (only used when `length` is not an
|
|
52
|
+
# array).
|
|
53
|
+
# @option options :phase [Number] (0)
|
|
54
|
+
# The distance into the dash pattern at which to start the dash. For
|
|
55
|
+
# example, a phase of 0 starts at the beginning of the dash; whereas,
|
|
56
|
+
# if the phase is equal to the length of the dash, then stroking will
|
|
57
|
+
# begin at the beginning of the space.
|
|
58
|
+
# @return [void]
|
|
59
|
+
def dash(length = nil, options = {})
|
|
60
|
+
return current_dash_state if length.nil?
|
|
61
|
+
|
|
62
|
+
length = Array(length)
|
|
63
|
+
|
|
64
|
+
if length.all?(&:zero?)
|
|
65
|
+
raise ArgumentError,
|
|
66
|
+
'Zero length dashes are invalid. Call #undash to disable dashes.'
|
|
67
|
+
elsif length.any?(&:negative?)
|
|
68
|
+
raise ArgumentError,
|
|
69
|
+
'Negative numbers are not allowed for dash lengths.'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
length = length.first if length.length == 1
|
|
73
|
+
|
|
74
|
+
self.current_dash_state = {
|
|
75
|
+
dash: length,
|
|
76
|
+
space: length.is_a?(Array) ? nil : options[:space] || length,
|
|
77
|
+
phase: options[:phase] || 0,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
write_stroke_dash
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
alias dash= dash
|
|
84
|
+
|
|
85
|
+
# Stops dashing, restoring solid stroked lines and curves.
|
|
86
|
+
#
|
|
87
|
+
# @return [void]
|
|
88
|
+
def undash
|
|
89
|
+
self.current_dash_state = undashed_setting
|
|
90
|
+
write_stroke_dash
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Returns `true` when stroke is dashed, `false` otherwise.
|
|
94
|
+
#
|
|
95
|
+
# @return [Boolean]
|
|
96
|
+
def dashed?
|
|
97
|
+
current_dash_state != undashed_setting
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
def write_stroke_dash
|
|
103
|
+
renderer.add_content(dash_setting)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def undashed_setting
|
|
107
|
+
{ dash: nil, space: nil, phase: 0 }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def current_dash_state=(dash_options)
|
|
111
|
+
graphic_state.dash = dash_options
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def current_dash_state
|
|
115
|
+
graphic_state.dash
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def dash_setting
|
|
119
|
+
graphic_state.dash_setting
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Prawn
|
|
4
|
+
module Graphics
|
|
5
|
+
# Implements stroke join styling.
|
|
6
|
+
module JoinStyle
|
|
7
|
+
# @private
|
|
8
|
+
JOIN_STYLES = { miter: 0, round: 1, bevel: 2 }.freeze
|
|
9
|
+
|
|
10
|
+
# @group Stable API
|
|
11
|
+
|
|
12
|
+
# Get or set the join style for stroked lines and curves.
|
|
13
|
+
#
|
|
14
|
+
# @overload join_style
|
|
15
|
+
# Get current join style.
|
|
16
|
+
#
|
|
17
|
+
# @return [:miter, :round, :bevel]
|
|
18
|
+
#
|
|
19
|
+
# @overload join_style(style)
|
|
20
|
+
# Set join style.
|
|
21
|
+
#
|
|
22
|
+
# @note If this method is never called, `:miter` will be used for join
|
|
23
|
+
# style throughout the document.
|
|
24
|
+
#
|
|
25
|
+
# @param style [:miter, :round, :bevel]
|
|
26
|
+
# @return [void]
|
|
27
|
+
#
|
|
28
|
+
#
|
|
29
|
+
def join_style(style = nil)
|
|
30
|
+
return current_join_style || :miter if style.nil?
|
|
31
|
+
|
|
32
|
+
self.current_join_style = style
|
|
33
|
+
|
|
34
|
+
unless JOIN_STYLES.key?(current_join_style)
|
|
35
|
+
raise Prawn::Errors::InvalidJoinStyle,
|
|
36
|
+
"#{style} is not a recognized join style. Valid styles are " +
|
|
37
|
+
JOIN_STYLES.keys.join(', ')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
write_stroke_join_style
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
alias join_style= join_style
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def current_join_style
|
|
48
|
+
graphic_state.join_style
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def current_join_style=(style)
|
|
52
|
+
graphic_state.join_style = style
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def write_stroke_join_style
|
|
56
|
+
renderer.add_content("#{JOIN_STYLES[current_join_style]} j")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|