ifmapper 2.2.2 → 2.2.3
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 +4 -4
- data/IFMapper.gemspec +3 -3
- data/lib/IFMapper/PDFMapExporter.rb +2 -521
- data/lib/IFMapper/PDFMapExporter_prawn.rb +100 -100
- data/maps/CityOfSecrets.map +0 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f57618e8827e75064b59271aed043f7e75debb7eaac3a26c141ef78b363bcf
|
4
|
+
data.tar.gz: 3e0f0226e2d80b52eb9db23c7f576e9c3bbad8d6451a246a78a54a712d1c8485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d93d099544d7272af51879188c005a12a2ad88db8c6109a8e718cc9d53334225f8068471c1d25f9faae799d512eb456910173ebc71f98fff67501fb6c7291e
|
7
|
+
data.tar.gz: a8e4c0daac7bd03cc9bc5607b3d43134a46c4a32e22db988ec2b92cef8a708c56fac5778fea8b1fc1cd0ccb8df7cb443a76c40e3d848afe5a4fcf3ca4f17663f
|
data/IFMapper.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
|
3
|
-
VERSION = '2.2.
|
3
|
+
VERSION = '2.2.3'
|
4
4
|
AUTHOR = "Gonzalo Garramuno"
|
5
5
|
HOMEPAGE = 'http://ggarra13.github.io/ifmapper/en/start.html'
|
6
6
|
EMAIL = 'ggarra13@gmail.com'
|
@@ -28,9 +28,9 @@ gem = Gem::Specification.new do |s|
|
|
28
28
|
EOF
|
29
29
|
s.add_runtime_dependency("rake-compiler", "~> 0.7.1", ">= 0.7.1" )
|
30
30
|
s.add_runtime_dependency("fxruby", "~> 1.6.0", ">= 1.6.0")
|
31
|
-
s.add_runtime_dependency("
|
31
|
+
s.add_runtime_dependency("prawn", "~> 1.0.0", ">= 1.0.0")
|
32
32
|
s.extra_rdoc_files = ["HISTORY.txt", "TODO.txt"] +
|
33
33
|
Dir.glob("docs/*/*")
|
34
|
-
s.rubyforge_project = 'ifmapper'
|
34
|
+
# s.rubyforge_project = 'ifmapper'
|
35
35
|
s.required_ruby_version = '>= 2.0.0'
|
36
36
|
end
|
@@ -1,526 +1,7 @@
|
|
1
|
-
|
2
1
|
require 'tmpdir'
|
3
2
|
|
4
3
|
begin
|
5
|
-
require '
|
4
|
+
require 'IFMapper/PDFMapExporter_prawn'
|
6
5
|
rescue LoadError => e
|
7
|
-
|
8
|
-
if $rubygems
|
9
|
-
err += "You can usually do so if you do 'gem install pdf-writer'."
|
10
|
-
else
|
11
|
-
err += "You can download it from www.rubyforge.net."
|
12
|
-
end
|
13
|
-
raise LoadError, err
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'IFMapper/MapPrinting'
|
17
|
-
|
18
|
-
PDF_ZOOM = 0.5
|
19
|
-
PDF_ROOM_WIDTH = W * PDF_ZOOM
|
20
|
-
PDF_ROOM_HEIGHT = H * PDF_ZOOM
|
21
|
-
PDF_ROOM_WS = WS * PDF_ZOOM
|
22
|
-
PDF_ROOM_HS = HS * PDF_ZOOM
|
23
|
-
PDF_MARGIN = 20.0
|
24
|
-
|
25
|
-
#
|
26
|
-
# Open all the map class and add all pdf methods there
|
27
|
-
# Gotta love Ruby's flexibility to just inject in new methods.
|
28
|
-
#
|
29
|
-
class FXConnection
|
30
|
-
def _cvt_pt(p, opts)
|
31
|
-
x = (p[0] - WW / 2.0) / WW.to_f
|
32
|
-
y = (p[1] - HH / 2.0) / HH.to_f
|
33
|
-
x = x * opts['ww'] + opts['ws_2'] + opts['margin_2'] + opts['w'] / 2.0
|
34
|
-
y = (opts['height'] - y) * opts['hh'] + opts['hs_2'] + opts['margin_2'] + opts['hs']
|
35
|
-
return [x, y]
|
36
|
-
end
|
37
|
-
|
38
|
-
def pdf_draw_arrow(pdf, opts, x1, y1, x2, y2)
|
39
|
-
return if @dir == BOTH
|
40
|
-
|
41
|
-
pt1, d = _arrow_info( x1, y1, x2, y2, 0.5 )
|
42
|
-
|
43
|
-
p = []
|
44
|
-
p << PDF::Writer::PolygonPoint.new( pt1[0], pt1[1] )
|
45
|
-
p << PDF::Writer::PolygonPoint.new( pt1[0] + d[0], pt1[1] - d[1] )
|
46
|
-
p << PDF::Writer::PolygonPoint.new( pt1[0] + d[1], pt1[1] + d[0] )
|
47
|
-
pdf.fill_color Color::RGB::Black
|
48
|
-
pdf.polygon(p).fill
|
49
|
-
end
|
50
|
-
|
51
|
-
def pdf_draw_complex_as_bspline( pdf, opts )
|
52
|
-
p = []
|
53
|
-
p << _cvt_pt(@pts[0], opts)
|
54
|
-
p << p[0]
|
55
|
-
p << p[0]
|
56
|
-
@pts.each { |pt|
|
57
|
-
p << _cvt_pt(pt, opts)
|
58
|
-
}
|
59
|
-
p << p[-1]
|
60
|
-
p << p[-1]
|
61
|
-
p << p[-1]
|
62
|
-
return FXSpline::bspline(p)
|
63
|
-
end
|
64
|
-
|
65
|
-
# PRE: If it's a loop exit that comes back to the same place, let's move
|
66
|
-
# it up and right
|
67
|
-
def pdf_draw_complex_as_lines( pdf, opts )
|
68
|
-
p = []
|
69
|
-
maxy = opts['height'] * opts['hh'] + opts['hs_2'] + opts['margin_2']
|
70
|
-
@pts.each { |pt|
|
71
|
-
if loop? == true
|
72
|
-
p << [ pt[0] * PDF_ZOOM + 10, maxy - pt[1] * PDF_ZOOM + 48 ]
|
73
|
-
else
|
74
|
-
p << [ pt[0] * PDF_ZOOM, maxy - pt[1] * PDF_ZOOM ]
|
75
|
-
end
|
76
|
-
}
|
77
|
-
return p
|
78
|
-
end
|
79
|
-
|
80
|
-
def pdf_draw_door( pdf, x1, y1, x2, y2 )
|
81
|
-
v = [ (x2-x1), (y2-y1) ]
|
82
|
-
t = 10 / Math.sqrt(v[0]*v[0]+v[1]*v[1])
|
83
|
-
v = [ v[0]*t, v[1]*t ]
|
84
|
-
m = [ (x2+x1)/2, (y2+y1)/2 ]
|
85
|
-
x1, y1 = [m[0] + v[1], m[1] - v[0]]
|
86
|
-
x2, y2 = [m[0] - v[1], m[1] + v[0]]
|
87
|
-
if @type == LOCKED_DOOR
|
88
|
-
pdf.move_to(x1, y1)
|
89
|
-
pdf.line_to(x2, y2).stroke
|
90
|
-
else
|
91
|
-
s = PDF::Writer::StrokeStyle.new(1,
|
92
|
-
:cap => :butt,
|
93
|
-
:join => :miter,
|
94
|
-
:dash => PDF::Writer::StrokeStyle::SOLID_LINE )
|
95
|
-
pdf.stroke_style(s)
|
96
|
-
v = [ v[0] / 3, v[1] / 3]
|
97
|
-
pdf.move_to(x1 - v[0], y1 - v[1])
|
98
|
-
pdf.line_to(x1 + v[0], y1 + v[1])
|
99
|
-
pdf.line_to(x2 + v[0], y2 + v[1])
|
100
|
-
pdf.line_to(x2 - v[0], y2 - v[1])
|
101
|
-
pdf.line_to(x1 - v[0], y1 - v[1])
|
102
|
-
pdf.stroke
|
103
|
-
s = PDF::Writer::StrokeStyle.new(2,
|
104
|
-
:cap => :butt,
|
105
|
-
:join => :miter,
|
106
|
-
:dash => PDF::Writer::StrokeStyle::SOLID_LINE )
|
107
|
-
pdf.stroke_style(s)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def pdf_draw_complex( pdf, opts )
|
112
|
-
if opts['Paths as Curves']
|
113
|
-
if @room[0] == @room[1]
|
114
|
-
dirA, dirB = dirs
|
115
|
-
if dirA == dirB
|
116
|
-
p = pdf_draw_complex_as_lines( pdf, opts )
|
117
|
-
else
|
118
|
-
p = pdf_draw_complex_as_bspline( pdf, opts )
|
119
|
-
end
|
120
|
-
else
|
121
|
-
p = pdf_draw_complex_as_bspline( pdf, opts )
|
122
|
-
end
|
123
|
-
else
|
124
|
-
p = pdf_draw_complex_as_lines( pdf, opts )
|
125
|
-
end
|
126
|
-
pdf.move_to( p[0][0], p[0][1] )
|
127
|
-
p.each { |pt| pdf.line_to( pt[0], pt[1] ) }
|
128
|
-
pdf.stroke
|
129
|
-
|
130
|
-
x1, y1 = [p[0][0], p[0][1]]
|
131
|
-
x2, y2 = [p[-1][0], p[-1][1]]
|
132
|
-
pdf_draw_arrow(pdf, opts, x1, y1, x2, y2)
|
133
|
-
|
134
|
-
if @type == LOCKED_DOOR or @type == CLOSED_DOOR
|
135
|
-
t = p.size / 2
|
136
|
-
x1, y1 = [ p[t][0], p[t][1] ]
|
137
|
-
x2, y2 = [ p[t-2][0], p[t-2][1] ]
|
138
|
-
pdf_draw_door(pdf, x1, y1, x2, y2)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def pdf_draw_simple(pdf, opts)
|
143
|
-
return if not @room[1] # PDF does not print unfinished complex connections
|
144
|
-
|
145
|
-
dir = @room[0].exits.index(self)
|
146
|
-
x1, y1 = @room[0].pdf_corner(opts, self, dir)
|
147
|
-
x2, y2 = @room[1].pdf_corner(opts, self)
|
148
|
-
pdf.move_to(x1, y1)
|
149
|
-
pdf.line_to(x2, y2).stroke
|
150
|
-
pdf_draw_arrow(pdf, opts, x1, y1, x2, y2)
|
151
|
-
if @type == LOCKED_DOOR or @type == CLOSED_DOOR
|
152
|
-
pdf_draw_door(pdf, x1, y1, x2, y2)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
#
|
157
|
-
# Draw the connection text next to the arrow ('I', 'O', etc)
|
158
|
-
#
|
159
|
-
def pdf_draw_text(pdf, x, y, dir, text, arrow)
|
160
|
-
if dir == 7 or dir < 6 and dir != 1
|
161
|
-
if arrow and (dir == 0 or dir == 4)
|
162
|
-
x += 5
|
163
|
-
end
|
164
|
-
x += 2.5
|
165
|
-
elsif dir == 6 or dir == 1
|
166
|
-
x -= 7.5
|
167
|
-
end
|
168
|
-
|
169
|
-
if dir > 5 or dir < 4
|
170
|
-
if arrow and (dir == 6 or dir == 2)
|
171
|
-
y += 5
|
172
|
-
end
|
173
|
-
y += 2.5
|
174
|
-
elsif dir == 4 or dir == 5
|
175
|
-
y -= 7.5
|
176
|
-
end
|
177
|
-
|
178
|
-
font_size = 8
|
179
|
-
pdf.add_text(x, y, text, font_size)
|
180
|
-
end
|
181
|
-
|
182
|
-
def pdf_draw_exit_text(pdf, opts)
|
183
|
-
|
184
|
-
if @exitText[0] != 0
|
185
|
-
dir = @room[0].exits.index(self)
|
186
|
-
x, y = @room[0].pdf_corner(opts, self, dir)
|
187
|
-
pdf_draw_text( pdf, x, y, dir,
|
188
|
-
EXIT_TEXT[@exitText[0]], @dir == BtoA)
|
189
|
-
end
|
190
|
-
|
191
|
-
if @exitText[1] != 0
|
192
|
-
dir = @room[1].exits.rindex(self)
|
193
|
-
x, y = @room[1].pdf_corner(opts, self, dir)
|
194
|
-
pdf_draw_text( pdf, x, y, dir,
|
195
|
-
EXIT_TEXT[@exitText[1]], @dir == AtoB)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def pdf_draw(pdf, opts)
|
200
|
-
pdf_draw_exit_text(pdf, opts)
|
201
|
-
if @type == SPECIAL
|
202
|
-
s = PDF::Writer::StrokeStyle.new(2, :dash => {
|
203
|
-
:pattern => [2],
|
204
|
-
:phase => [1]
|
205
|
-
} )
|
206
|
-
else
|
207
|
-
s = PDF::Writer::StrokeStyle.new(2,
|
208
|
-
:cap => :butt,
|
209
|
-
:join => :miter,
|
210
|
-
:dash => PDF::Writer::StrokeStyle::SOLID_LINE )
|
211
|
-
end
|
212
|
-
pdf.stroke_style( s )
|
213
|
-
pdf.stroke_color Color::RGB::Black
|
214
|
-
pdf.fill_color Color::RGB::Black
|
215
|
-
if @pts.size > 0
|
216
|
-
pdf_draw_complex(pdf, opts)
|
217
|
-
else
|
218
|
-
pdf_draw_simple(pdf, opts)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
|
-
class FXRoom
|
225
|
-
def pdf_corner( opts, c, idx = nil )
|
226
|
-
x, y = _corner(c, idx)
|
227
|
-
y = -y
|
228
|
-
|
229
|
-
ww = opts['ww']
|
230
|
-
hh = opts['hh']
|
231
|
-
w = opts['w']
|
232
|
-
h = opts['h']
|
233
|
-
|
234
|
-
ry = opts['height'] - @y
|
235
|
-
x = @x * ww + opts['ws_2'] + opts['margin_2'] + x * w
|
236
|
-
y = ry * hh + opts['hs_2'] + h + opts['margin_2'] + y * h
|
237
|
-
return [x, y]
|
238
|
-
end
|
239
|
-
|
240
|
-
|
241
|
-
def pdf_draw_box( pdf, opts, idx, pdflocationnos )
|
242
|
-
x = @x * opts['ww'] + opts['ws_2'] + opts['margin_2']
|
243
|
-
y = (opts['height'] - @y) * opts['hh'] + opts['hs_2'] + opts['margin_2']
|
244
|
-
|
245
|
-
s = PDF::Writer::StrokeStyle::DEFAULT
|
246
|
-
pdf.stroke_style( s )
|
247
|
-
|
248
|
-
if @darkness
|
249
|
-
pdf.fill_color( Color::RGB::Gray )
|
250
|
-
else
|
251
|
-
pdf.fill_color( Color::RGB::White )
|
252
|
-
end
|
253
|
-
|
254
|
-
pdf.rectangle(x, y, opts['w'], opts['h']).fill_stroke
|
255
|
-
|
256
|
-
if pdflocationnos == 1
|
257
|
-
# PRE: Draw a rectangle for the location number
|
258
|
-
pdf.rectangle((x+opts['w']-opts['w']/4), y, opts['w']/4, opts['h']/4).fill_stroke
|
259
|
-
|
260
|
-
# PRE: Pad out the number so it is three chars long
|
261
|
-
locationno = (idx+1).to_s
|
262
|
-
if (idx+1) < 10
|
263
|
-
locationno = ' '+locationno
|
264
|
-
elsif (idx+1) < 100
|
265
|
-
locationno = ' '+locationno
|
266
|
-
end
|
267
|
-
|
268
|
-
# PRE: Write the location number
|
269
|
-
pdf.fill_color(Color::RGB::Black)
|
270
|
-
pdf.add_text((x+((opts['w']/4)*3)+2), y+2, locationno, 8)
|
271
|
-
end
|
272
|
-
|
273
|
-
end
|
274
|
-
|
275
|
-
def pdf_draw_text( pdf, opts, x, y, text, font_size, pdflocationnos )
|
276
|
-
miny = (opts['height'] - @y) * opts['hh'] + opts['hs_2'] +
|
277
|
-
opts['margin_2']
|
278
|
-
while text != ''
|
279
|
-
# PRE: Wrap the text to avoid the location number box
|
280
|
-
if (y >= miny) and (y <= (miny+font_size)) and (pdflocationnos == 1)
|
281
|
-
wrapwidthmodifier = 15
|
282
|
-
else
|
283
|
-
wrapwidthmodifier = 2
|
284
|
-
end
|
285
|
-
text = pdf.add_text_wrap(x, y, opts['w'] - wrapwidthmodifier, text, font_size)
|
286
|
-
y -= font_size
|
287
|
-
break if y <= miny
|
288
|
-
end
|
289
|
-
return [x, y]
|
290
|
-
end
|
291
|
-
|
292
|
-
def pdf_draw_objects(pdf, opts, x, y, pdflocationnos)
|
293
|
-
font_size = 6
|
294
|
-
objs = @objects.split("\n")
|
295
|
-
objs = objs.join(', ')
|
296
|
-
return pdf_draw_text( pdf, opts, x, y, objs, font_size, pdflocationnos )
|
297
|
-
end
|
298
|
-
|
299
|
-
def pdf_draw_name(pdf, opts, pdflocationnos)
|
300
|
-
# We could also use pdf_corner(7) here
|
301
|
-
x = @x * opts['ww'] + opts['margin_2'] + opts['ws_2'] + 2
|
302
|
-
y = opts['height'] - @y
|
303
|
-
font_size = 8
|
304
|
-
y = y * opts['hh'] + opts['margin_2'] + opts['hs_2'] + opts['h'] -
|
305
|
-
(font_size + 2)
|
306
|
-
pdf.stroke_color(Color::RGB::Black)
|
307
|
-
pdf.fill_color(Color::RGB::Black)
|
308
|
-
return pdf_draw_text( pdf, opts, x, y, @name, font_size, pdflocationnos )
|
309
|
-
end
|
310
|
-
|
311
|
-
# PRE: Send through the index so we can print the location number
|
312
|
-
# along with boolean value indicating whether the user wants them
|
313
|
-
def pdf_draw( pdf, opts, idx, pdflocationnos )
|
314
|
-
pdf_draw_box( pdf, opts, idx, pdflocationnos )
|
315
|
-
x, y = pdf_draw_name( pdf, opts, pdflocationnos )
|
316
|
-
pdf_draw_objects(pdf, opts, x, y, pdflocationnos)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
class FXSection
|
323
|
-
|
324
|
-
def pdf_draw_grid(pdf, opts, w, h )
|
325
|
-
(0...w).each { |xx|
|
326
|
-
(0...h).each { |yy|
|
327
|
-
x = xx * opts['ww'] + opts['ws_2'] + opts['margin_2']
|
328
|
-
y = yy * opts['hh'] + opts['hs_2'] + opts['margin_2']
|
329
|
-
pdf.rectangle(x, y, opts['w'], opts['h']).stroke
|
330
|
-
}
|
331
|
-
}
|
332
|
-
end
|
333
|
-
|
334
|
-
|
335
|
-
def pdf_draw_section_name( pdf, opts, px, py )
|
336
|
-
return if not @name or @name == ''
|
337
|
-
xymin, xymax = min_max_rooms
|
338
|
-
text = @name
|
339
|
-
text += " (#{px}, #{py})" if px > 0 or py > 0
|
340
|
-
y = (opts['height']) * opts['hh'] + 16
|
341
|
-
w = xymax[0]
|
342
|
-
w = opts['width'] if w > opts['width']
|
343
|
-
x = (w + 2) * opts['ww'] / 2 - text.size / 2 * 16
|
344
|
-
x = 0 if x < 0
|
345
|
-
pdf.add_text( x, y, text, 16 )
|
346
|
-
end
|
347
|
-
|
348
|
-
|
349
|
-
def pdf_draw(pdf, opts, mapname, pdflocationnos )
|
350
|
-
|
351
|
-
|
352
|
-
w, h = rooms_width_height
|
353
|
-
x, y = [0, 0]
|
354
|
-
|
355
|
-
loop do
|
356
|
-
|
357
|
-
if rotate
|
358
|
-
pdf.rotate_axis(90.0)
|
359
|
-
pdf.translate_axis( 0, -pdf.page_height )
|
360
|
-
end
|
361
|
-
|
362
|
-
# Move section to its position in page
|
363
|
-
tx1, ty1 = [@xoff * opts['ww'], @yoff * -opts['hh']]
|
364
|
-
pdf.translate_axis( tx1, ty1 )
|
365
|
-
|
366
|
-
# Use times-roman as font
|
367
|
-
pdf.select_font 'Times-Roman'
|
368
|
-
pdf.stroke_color(Color::RGB::Black)
|
369
|
-
pdf.fill_color(Color::RGB::Black)
|
370
|
-
|
371
|
-
pdf_draw_section_name( pdf, opts, x, y )
|
372
|
-
|
373
|
-
xymin, = min_max_rooms
|
374
|
-
|
375
|
-
# Move rooms, so that we don't print empty areas
|
376
|
-
tx2 = -(xymin[0]) * opts['ww'] - x * opts['ww']
|
377
|
-
ty2 = (xymin[1]) * opts['hh'] - 60 + (y - (y > 0? 1 : 0)) * opts['hh']
|
378
|
-
pdf.translate_axis( tx2, ty2 )
|
379
|
-
|
380
|
-
|
381
|
-
# For testing purposes only, draw grid of boxes
|
382
|
-
# pdf_draw_grid( pdf, opts, w, h )
|
383
|
-
@connections.each { |c|
|
384
|
-
a = c.roomA
|
385
|
-
b = c.roomB
|
386
|
-
next if a.y < y and b and b.y < y
|
387
|
-
c.pdf_draw( pdf, opts )
|
388
|
-
}
|
389
|
-
@rooms.each_with_index { |r, idx|
|
390
|
-
next if r.y < y
|
391
|
-
r.pdf_draw( pdf, opts, idx, pdflocationnos)
|
392
|
-
}
|
393
|
-
|
394
|
-
# Reset axis
|
395
|
-
pdf.translate_axis(-tx2, -ty2)
|
396
|
-
pdf.translate_axis(-tx1, -ty1)
|
397
|
-
|
398
|
-
xi = opts['width']
|
399
|
-
yi = opts['height']
|
400
|
-
if rotate
|
401
|
-
xi = (pdf.page_height / opts['ww']).to_i - 1
|
402
|
-
yi = (pdf.page_width / opts['hh']).to_i - 1
|
403
|
-
end
|
404
|
-
|
405
|
-
x += xi
|
406
|
-
if x >= w
|
407
|
-
x = 0
|
408
|
-
y += yi
|
409
|
-
break if y >= h
|
410
|
-
end
|
411
|
-
|
412
|
-
if rotate
|
413
|
-
pdf.rotate_axis(-90.0)
|
414
|
-
pdf.translate_axis( 0, pdf.page_height )
|
415
|
-
end
|
416
|
-
|
417
|
-
# We could not fit all rooms in page. Start new page
|
418
|
-
pdf.start_new_page
|
419
|
-
end
|
420
|
-
end
|
421
|
-
end
|
422
|
-
|
423
|
-
|
424
|
-
class FXMap
|
425
|
-
|
426
|
-
attr_accessor :pdfpapersize
|
427
|
-
# boolean value indicating whether the user wants to see location nos
|
428
|
-
attr_accessor :pdflocationnos
|
429
|
-
|
430
|
-
def pdf_draw_mapname( pdf, opts )
|
431
|
-
return if not @name or @name == ''
|
432
|
-
pdf.text( @name,
|
433
|
-
:font_size => 24,
|
434
|
-
:justification => :center
|
435
|
-
)
|
436
|
-
end
|
437
|
-
|
438
|
-
def pdf_draw_sections( pdf, opts )
|
439
|
-
old_section = @section
|
440
|
-
page = -1
|
441
|
-
@sections.each_with_index { |sect, idx|
|
442
|
-
if page != sect.page
|
443
|
-
page = sect.page
|
444
|
-
pdf.start_new_page if page > 1
|
445
|
-
pdf_draw_mapname( pdf, opts )
|
446
|
-
end
|
447
|
-
@section = idx
|
448
|
-
# For each page, we need to regenerate the pathmap so that complex
|
449
|
-
# paths will come out ok.
|
450
|
-
create_pathmap
|
451
|
-
# Now, we draw it
|
452
|
-
sect.pdf_draw(pdf, opts, @name, pdflocationnos)
|
453
|
-
}
|
454
|
-
|
455
|
-
# Restore original viewing page
|
456
|
-
@section = old_section
|
457
|
-
create_pathmap
|
458
|
-
end
|
459
|
-
|
460
|
-
|
461
|
-
def pdf_export(pdffile = Dir::tmpdir + "/ifmap.pdf", printer = nil)
|
462
|
-
|
463
|
-
# PRE: Let's set the PDF paper size to user's choice
|
464
|
-
paper = BOX_PDF_PAGE_SIZE_TEXT[pdfpapersize]
|
465
|
-
if printer
|
466
|
-
case printer.mediasize
|
467
|
-
when FXPrinter::MEDIA_LETTER
|
468
|
-
paper = 'LETTER'
|
469
|
-
when FXPrinter::MEDIA_LEGAL
|
470
|
-
paper = 'LEGAL'
|
471
|
-
when FXPrinter::MEDIA_A4
|
472
|
-
paper = 'A4'
|
473
|
-
when FXPrinter::MEDIA_ENVELOPE
|
474
|
-
paper = 'ENVELOPE'
|
475
|
-
when FXPrinter::MEDIA_CUSTOM
|
476
|
-
raise "Sorry, custom paper not supported"
|
477
|
-
end
|
478
|
-
end
|
479
|
-
|
480
|
-
# Open a new PDF writer with paper selected
|
481
|
-
# PRE: Let's also set the paper orientation based on user selection
|
482
|
-
pdf = PDF::Writer.new :paper => paper
|
483
|
-
|
484
|
-
pdf.margins_pt 0
|
485
|
-
|
486
|
-
pdf_options = @options.dup
|
487
|
-
|
488
|
-
ww = PDF_ROOM_WIDTH + PDF_ROOM_WS
|
489
|
-
hh = PDF_ROOM_HEIGHT + PDF_ROOM_HS
|
490
|
-
|
491
|
-
pdf_options.merge!(
|
492
|
-
{
|
493
|
-
'ww' => ww,
|
494
|
-
'hh' => hh,
|
495
|
-
'w' => PDF_ROOM_WIDTH,
|
496
|
-
'h' => PDF_ROOM_HEIGHT,
|
497
|
-
'ws' => PDF_ROOM_WS,
|
498
|
-
'hs' => PDF_ROOM_HS,
|
499
|
-
'ws_2' => PDF_ROOM_WS / 2.0,
|
500
|
-
'hs_2' => PDF_ROOM_HS / 2.0,
|
501
|
-
'margin' => PDF_MARGIN,
|
502
|
-
'margin_2' => PDF_MARGIN / 2.0,
|
503
|
-
'width' => (pdf.page_width / ww).to_i - 1,
|
504
|
-
'height' => (pdf.page_height / hh).to_i - 1,
|
505
|
-
}
|
506
|
-
)
|
507
|
-
|
508
|
-
|
509
|
-
begin
|
510
|
-
# See if it is possible to pack several map sections (sections) into
|
511
|
-
# a single print page.
|
512
|
-
num = pack_sections( pdf_options['width'] + 2,
|
513
|
-
pdf_options['height'] + 2 )
|
514
|
-
pdf_draw_sections(pdf, pdf_options)
|
515
|
-
if pdffile !~ /\.pdf$/
|
516
|
-
pdffile << ".pdf"
|
517
|
-
end
|
518
|
-
status "Exporting PDF file '#{pdffile}'"
|
519
|
-
pdf.save_as(pdffile)
|
520
|
-
rescue => e
|
521
|
-
p e
|
522
|
-
p e.backtrace
|
523
|
-
raise e
|
524
|
-
end
|
525
|
-
end
|
6
|
+
raise LoadError, e
|
526
7
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'tmpdir'
|
3
2
|
|
4
3
|
begin
|
@@ -16,8 +15,8 @@ end
|
|
16
15
|
require 'IFMapper/MapPrinting'
|
17
16
|
|
18
17
|
PDF_ZOOM = 0.5
|
19
|
-
PDF_ROOM_WIDTH = W * PDF_ZOOM
|
20
|
-
PDF_ROOM_HEIGHT = H * PDF_ZOOM
|
18
|
+
PDF_ROOM_WIDTH = W * PDF_ZOOM
|
19
|
+
PDF_ROOM_HEIGHT = H * PDF_ZOOM
|
21
20
|
PDF_ROOM_WS = WS * PDF_ZOOM
|
22
21
|
PDF_ROOM_HS = HS * PDF_ZOOM
|
23
22
|
PDF_MARGIN = 20.0
|
@@ -37,14 +36,14 @@ class FXConnection
|
|
37
36
|
|
38
37
|
def pdf_draw_arrow(pdf, opts, x1, y1, x2, y2)
|
39
38
|
return if @dir == BOTH
|
40
|
-
|
39
|
+
|
41
40
|
pt1, d = _arrow_info( x1, y1, x2, y2, 0.5 )
|
42
|
-
|
41
|
+
|
43
42
|
pdf.stroke_color '000000'
|
44
43
|
pdf.fill_color '000000'
|
45
|
-
pdf.fill_polygon( [ pt1[0], pt1[1] ],
|
46
|
-
[ pt1[0] + d[0], pt1[1] - d[1] ],
|
47
|
-
[ pt1[0] + d[
|
44
|
+
pdf.fill_polygon( [ pt1[0], pt1[1] ],
|
45
|
+
[ pt1[0] + d[0], pt1[1] - d[1] ],
|
46
|
+
[ pt1[0] + d[1], pt1[1] + d[0] ] )
|
48
47
|
end
|
49
48
|
|
50
49
|
def pdf_draw_complex_as_bspline( pdf, opts )
|
@@ -61,11 +60,11 @@ class FXConnection
|
|
61
60
|
return FXSpline::bspline(p)
|
62
61
|
end
|
63
62
|
|
64
|
-
# PRE: If it's a loop exit that comes back to the same place, let's move
|
63
|
+
# PRE: If it's a loop exit that comes back to the same place, let's move
|
65
64
|
# it up and right
|
66
65
|
def pdf_draw_complex_as_lines( pdf, opts )
|
67
66
|
p = []
|
68
|
-
maxy = opts['height'] * opts['hh'] + opts['hs_2'] + opts['margin_2']
|
67
|
+
maxy = opts['height'] * opts['hh'] + opts['hs_2'] + opts['margin_2']
|
69
68
|
@pts.each { |pt|
|
70
69
|
if loop? == true
|
71
70
|
p << [ pt[0] * PDF_ZOOM + 10, maxy - pt[1] * PDF_ZOOM + 48 ]
|
@@ -88,6 +87,7 @@ class FXConnection
|
|
88
87
|
if @type == LOCKED_DOOR
|
89
88
|
pdf.move_to(x1, y1)
|
90
89
|
pdf.line_to(x2, y2)
|
90
|
+
pdf.stroke
|
91
91
|
else
|
92
92
|
pdf.cap_style = :butt
|
93
93
|
pdf.join_style = :miter
|
@@ -99,6 +99,7 @@ class FXConnection
|
|
99
99
|
pdf.line_to(x2 + v[0], y2 + v[1])
|
100
100
|
pdf.line_to(x2 - v[0], y2 - v[1])
|
101
101
|
pdf.line_to(x1 - v[0], y1 - v[1])
|
102
|
+
pdf.stroke
|
102
103
|
|
103
104
|
pdf.cap_style = :butt
|
104
105
|
pdf.join_style = :miter
|
@@ -107,27 +108,24 @@ class FXConnection
|
|
107
108
|
end
|
108
109
|
|
109
110
|
def pdf_draw_complex( pdf, opts )
|
110
|
-
pdf.stroke_color '000000'
|
111
|
-
pdf.fill_color '000000'
|
112
111
|
if opts['Paths as Curves']
|
113
112
|
if @room[0] == @room[1]
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
113
|
+
dirA, dirB = dirs
|
114
|
+
if dirA == dirB
|
115
|
+
p = pdf_draw_complex_as_lines( pdf, opts )
|
116
|
+
else
|
117
|
+
p = pdf_draw_complex_as_bspline( pdf, opts )
|
118
|
+
end
|
120
119
|
else
|
121
|
-
|
120
|
+
p = pdf_draw_complex_as_bspline( pdf, opts )
|
122
121
|
end
|
123
122
|
else
|
124
123
|
p = pdf_draw_complex_as_lines( pdf, opts )
|
125
124
|
end
|
126
|
-
|
127
|
-
pdf.stroke_color '000000'
|
128
|
-
pdf.fill_color '000000'
|
125
|
+
|
129
126
|
pdf.move_to( p[0][0], p[0][1] )
|
130
127
|
p.each { |pt| pdf.line_to( pt[0], pt[1] ) }
|
128
|
+
pdf.stroke
|
131
129
|
|
132
130
|
x1, y1 = [p[0][0], p[0][1]]
|
133
131
|
x2, y2 = [p[-1][0], p[-1][1]]
|
@@ -147,10 +145,9 @@ class FXConnection
|
|
147
145
|
dir = @room[0].exits.index(self)
|
148
146
|
x1, y1 = @room[0].pdf_corner(opts, self, dir)
|
149
147
|
x2, y2 = @room[1].pdf_corner(opts, self)
|
150
|
-
pdf.stroke_color '000000'
|
151
|
-
pdf.fill_color '000000'
|
152
148
|
pdf.move_to(x1, y1)
|
153
149
|
pdf.line_to(x2, y2)
|
150
|
+
pdf.stroke
|
154
151
|
pdf_draw_arrow(pdf, opts, x1, y1, x2, y2)
|
155
152
|
if @type == LOCKED_DOOR or @type == CLOSED_DOOR
|
156
153
|
pdf_draw_door(pdf, x1, y1, x2, y2)
|
@@ -163,22 +160,22 @@ class FXConnection
|
|
163
160
|
def pdf_draw_text(pdf, x, y, dir, text, arrow)
|
164
161
|
if dir == 7 or dir < 6 and dir != 1
|
165
162
|
if arrow and (dir == 0 or dir == 4)
|
166
|
-
|
163
|
+
x += 5
|
167
164
|
end
|
168
165
|
x += 2.5
|
169
166
|
elsif dir == 6 or dir == 1
|
170
167
|
x -= 7.5
|
171
168
|
end
|
172
|
-
|
169
|
+
|
173
170
|
if dir > 5 or dir < 4
|
174
171
|
if arrow and (dir == 6 or dir == 2)
|
175
|
-
|
172
|
+
y += 5
|
176
173
|
end
|
177
174
|
y += 2.5
|
178
175
|
elsif dir == 4 or dir == 5
|
179
176
|
y -= 7.5
|
180
177
|
end
|
181
|
-
|
178
|
+
|
182
179
|
font_size = 8
|
183
180
|
pdf.text_box text, :at => [x, y], :size => font_size
|
184
181
|
end
|
@@ -189,20 +186,22 @@ class FXConnection
|
|
189
186
|
dir = @room[0].exits.index(self)
|
190
187
|
x, y = @room[0].pdf_corner(opts, self, dir)
|
191
188
|
pdf.move_to(x, y)
|
192
|
-
pdf_draw_text( pdf, x, y+4, dir,
|
189
|
+
pdf_draw_text( pdf, x, y+4, dir,
|
193
190
|
EXIT_TEXT[@exitText[0]], @dir == BtoA)
|
194
191
|
end
|
195
192
|
|
196
193
|
if @exitText[1] != 0
|
197
194
|
dir = @room[1].exits.rindex(self)
|
198
195
|
x, y = @room[1].pdf_corner(opts, self, dir)
|
199
|
-
pdf_draw_text( pdf, x, y+4, dir,
|
200
|
-
|
196
|
+
pdf_draw_text( pdf, x, y+4, dir,
|
197
|
+
EXIT_TEXT[@exitText[1]], @dir == AtoB)
|
201
198
|
end
|
202
199
|
end
|
203
200
|
|
204
201
|
def pdf_draw(pdf, opts)
|
205
202
|
pdf_draw_exit_text(pdf, opts)
|
203
|
+
pdf.stroke_color '000000'
|
204
|
+
pdf.fill_color '000000'
|
206
205
|
if @type == SPECIAL
|
207
206
|
pdf.dash 4
|
208
207
|
else
|
@@ -210,8 +209,6 @@ class FXConnection
|
|
210
209
|
pdf.join_style = :miter
|
211
210
|
pdf.undash
|
212
211
|
end
|
213
|
-
pdf.stroke_color '000000'
|
214
|
-
pdf.fill_color '000000'
|
215
212
|
if @pts.size > 0
|
216
213
|
pdf_draw_complex(pdf, opts)
|
217
214
|
else
|
@@ -245,10 +242,12 @@ class FXRoom
|
|
245
242
|
pdf.cap_style = :butt
|
246
243
|
pdf.join_style = :miter
|
247
244
|
pdf.line_width 1
|
245
|
+
pdf.undash
|
248
246
|
|
249
247
|
if @darkness
|
250
248
|
pdf.fill_color '808080'
|
251
249
|
pdf.stroke_color '000000'
|
250
|
+
pdf.fill_rectangle [x, y], opts['w'], -opts['h']
|
252
251
|
else
|
253
252
|
pdf.fill_color 'ffffff'
|
254
253
|
pdf.stroke_color '000000'
|
@@ -256,11 +255,12 @@ class FXRoom
|
|
256
255
|
|
257
256
|
pdf.stroke_rectangle [x, y], opts['w'], -opts['h']
|
258
257
|
|
258
|
+
|
259
259
|
if pdflocationnos == 1
|
260
260
|
# PRE: Draw a rectangle for the location number
|
261
|
-
pdf.stroke_rectangle( [x+opts['w']-opts['w']/4, y],
|
261
|
+
pdf.stroke_rectangle( [x+opts['w']-opts['w']/4, y],
|
262
262
|
opts['w']/4, -opts['h']/4 )
|
263
|
-
|
263
|
+
|
264
264
|
# PRE: Pad out the number so it is three chars long
|
265
265
|
locationno = (idx+1).to_s
|
266
266
|
if (idx+1) < 10
|
@@ -273,16 +273,16 @@ class FXRoom
|
|
273
273
|
pdf.stroke_color '000000'
|
274
274
|
pdf.fill_color '000000'
|
275
275
|
|
276
|
-
pdf.text_box locationno,
|
276
|
+
pdf.text_box locationno,
|
277
277
|
:at => [(x+((opts['w']/4)*3)+2), y+7], :size => 8
|
278
278
|
end
|
279
|
-
|
279
|
+
|
280
280
|
end
|
281
281
|
|
282
282
|
def pdf_draw_text( pdf, opts, x, y, text, font_size, pdflocationnos )
|
283
|
-
miny = (opts['height'] - @y) * opts['hh'] + opts['hs_2'] +
|
283
|
+
miny = (opts['height'] - @y) * opts['hh'] + opts['hs_2'] +
|
284
284
|
opts['margin_2']
|
285
|
-
pdf.text_box text, :at => [x, y+6], :size => font_size,
|
285
|
+
pdf.text_box text, :at => [x, y+6], :size => font_size,
|
286
286
|
:width => opts['w'], :height => opts['h'], :valign => :top,
|
287
287
|
:align => :left, :overflow => :shrink_to_fit
|
288
288
|
return [x, y]
|
@@ -292,7 +292,7 @@ class FXRoom
|
|
292
292
|
font_size = 6
|
293
293
|
objs = @objects.split("\n")
|
294
294
|
objs = objs.join(', ')
|
295
|
-
return pdf_draw_text( pdf, opts, x, y-font_size,
|
295
|
+
return pdf_draw_text( pdf, opts, x, y-font_size,
|
296
296
|
objs, font_size, pdflocationnos )
|
297
297
|
end
|
298
298
|
|
@@ -301,7 +301,7 @@ class FXRoom
|
|
301
301
|
x = @x * opts['ww'] + opts['margin_2'] + opts['ws_2'] + 2
|
302
302
|
y = opts['height'] - @y
|
303
303
|
font_size = 8
|
304
|
-
y = y * opts['hh'] + opts['margin_2'] + opts['hs_2'] + opts['h'] -
|
304
|
+
y = y * opts['hh'] + opts['margin_2'] + opts['hs_2'] + opts['h'] -
|
305
305
|
(font_size + 2)
|
306
306
|
pdf.stroke_color '000000'
|
307
307
|
pdf.fill_color '000000'
|
@@ -324,9 +324,9 @@ class FXSection
|
|
324
324
|
def pdf_draw_grid(pdf, opts, w, h )
|
325
325
|
(0...w).each { |xx|
|
326
326
|
(0...h).each { |yy|
|
327
|
-
|
328
|
-
|
329
|
-
|
327
|
+
x = xx * opts['ww'] + opts['ws_2'] + opts['margin_2']
|
328
|
+
y = yy * opts['hh'] + opts['hs_2'] + opts['margin_2']
|
329
|
+
pdf.rectangle([x, y], opts['w'], opts['h'])
|
330
330
|
}
|
331
331
|
}
|
332
332
|
end
|
@@ -356,9 +356,9 @@ class FXSection
|
|
356
356
|
|
357
357
|
pdf.save_graphics_state
|
358
358
|
|
359
|
-
if rotate
|
360
|
-
|
361
|
-
|
359
|
+
if rotate and @rooms.size > 2
|
360
|
+
pdf.rotate 90.0
|
361
|
+
pdf.translate( 0, -pdf.margin_box.height )
|
362
362
|
end
|
363
363
|
|
364
364
|
# Move section to its position in page
|
@@ -377,42 +377,42 @@ class FXSection
|
|
377
377
|
tx2 = -(xymin[0]) * opts['ww'] - x * opts['ww']
|
378
378
|
ty2 = (xymin[1]) * opts['hh'] - 60 + (y - (y > 0? 1 : 0)) * opts['hh']
|
379
379
|
pdf.translate( tx2, ty2 )
|
380
|
-
|
381
|
-
|
380
|
+
|
381
|
+
|
382
382
|
# For testing purposes only, draw grid of boxes
|
383
383
|
# pdf_draw_grid( pdf, opts, w, h )
|
384
|
-
@connections.each { |c|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
384
|
+
@connections.each { |c|
|
385
|
+
a = c.roomA
|
386
|
+
b = c.roomB
|
387
|
+
next if a.y < y and b and b.y < y
|
388
|
+
c.pdf_draw( pdf, opts )
|
389
389
|
}
|
390
|
-
@rooms.each_with_index { |r, idx|
|
391
|
-
|
392
|
-
|
390
|
+
@rooms.each_with_index { |r, idx|
|
391
|
+
next if r.y < y
|
392
|
+
r.pdf_draw( pdf, opts, idx, pdflocationnos)
|
393
393
|
}
|
394
|
-
|
394
|
+
|
395
395
|
# Reset axis
|
396
396
|
pdf.translate(-tx2, -ty2)
|
397
397
|
pdf.translate(-tx1, -ty1)
|
398
|
-
|
398
|
+
|
399
399
|
xi = opts['width']
|
400
400
|
yi = opts['height']
|
401
|
-
if rotate
|
402
|
-
|
403
|
-
|
401
|
+
if rotate and @rooms.size > 2
|
402
|
+
xi = (pdf.margin_box.height / opts['ww']).to_i - 1
|
403
|
+
yi = (pdf.margin_box.width / opts['hh']).to_i - 1
|
404
404
|
end
|
405
405
|
|
406
406
|
x += xi
|
407
407
|
if x >= w
|
408
|
-
|
409
|
-
|
410
|
-
|
408
|
+
x = 0
|
409
|
+
y += yi
|
410
|
+
break if y >= h
|
411
411
|
end
|
412
412
|
|
413
|
-
if rotate
|
414
|
-
|
415
|
-
|
413
|
+
if rotate and @rooms.size > 2
|
414
|
+
pdf.rotate(-90.0)
|
415
|
+
pdf.translate( 0, pdf.page_height )
|
416
416
|
end
|
417
417
|
|
418
418
|
pdf.restore_graphics_state
|
@@ -429,13 +429,13 @@ class FXMap
|
|
429
429
|
attr_accessor :pdfpapersize
|
430
430
|
# boolean value indicating whether the user wants to see location nos
|
431
431
|
attr_accessor :pdflocationnos
|
432
|
-
|
432
|
+
|
433
433
|
def pdf_draw_mapname( pdf, opts )
|
434
434
|
return if not @name or @name == ''
|
435
435
|
pdf.text( @name,
|
436
|
-
|
437
|
-
|
438
|
-
|
436
|
+
:font_size => 24,
|
437
|
+
:justification => :center
|
438
|
+
)
|
439
439
|
end
|
440
440
|
|
441
441
|
def pdf_draw_sections( pdf, opts )
|
@@ -443,9 +443,9 @@ class FXMap
|
|
443
443
|
page = -1
|
444
444
|
@sections.each_with_index { |sect, idx|
|
445
445
|
if page != sect.page
|
446
|
-
|
447
|
-
|
448
|
-
|
446
|
+
page = sect.page
|
447
|
+
pdf.start_new_page if page > 1
|
448
|
+
pdf_draw_mapname( pdf, opts )
|
449
449
|
end
|
450
450
|
@section = idx
|
451
451
|
# For each page, we need to regenerate the pathmap so that complex
|
@@ -462,27 +462,27 @@ class FXMap
|
|
462
462
|
|
463
463
|
|
464
464
|
def pdf_export(pdffile = Dir::tmpdir + "/ifmap.pdf", printer = nil)
|
465
|
-
|
465
|
+
|
466
466
|
# PRE: Let's set the PDF paper size to user's choice
|
467
467
|
paper = BOX_PDF_PAGE_SIZE_TEXT[pdfpapersize]
|
468
468
|
if printer
|
469
469
|
case printer.mediasize
|
470
470
|
when FXPrinter::MEDIA_LETTER
|
471
|
-
|
471
|
+
paper = 'LETTER'
|
472
472
|
when FXPrinter::MEDIA_LEGAL
|
473
|
-
|
473
|
+
paper = 'LEGAL'
|
474
474
|
when FXPrinter::MEDIA_A4
|
475
|
-
|
475
|
+
paper = 'A4'
|
476
476
|
when FXPrinter::MEDIA_ENVELOPE
|
477
|
-
|
477
|
+
paper = 'ENVELOPE'
|
478
478
|
when FXPrinter::MEDIA_CUSTOM
|
479
|
-
|
479
|
+
raise "Sorry, custom paper not supported"
|
480
480
|
end
|
481
481
|
end
|
482
482
|
|
483
483
|
# Open a new PDF writer with paper selected
|
484
484
|
# PRE: Let's also set the paper orientation based on user selection
|
485
|
-
|
485
|
+
|
486
486
|
pdf = Prawn::Document.new :page_size => paper
|
487
487
|
|
488
488
|
pdf_options = @options.dup
|
@@ -490,32 +490,32 @@ class FXMap
|
|
490
490
|
ww = PDF_ROOM_WIDTH + PDF_ROOM_WS
|
491
491
|
hh = PDF_ROOM_HEIGHT + PDF_ROOM_HS
|
492
492
|
|
493
|
-
pdf_options.merge!(
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
493
|
+
pdf_options.merge!(
|
494
|
+
{
|
495
|
+
'ww' => ww,
|
496
|
+
'hh' => hh,
|
497
|
+
'w' => PDF_ROOM_WIDTH,
|
498
|
+
'h' => PDF_ROOM_HEIGHT,
|
499
|
+
'ws' => PDF_ROOM_WS,
|
500
|
+
'hs' => PDF_ROOM_HS,
|
501
|
+
'ws_2' => PDF_ROOM_WS / 2.0,
|
502
|
+
'hs_2' => PDF_ROOM_HS / 2.0,
|
503
|
+
'margin' => PDF_MARGIN,
|
504
|
+
'margin_2' => PDF_MARGIN / 2.0,
|
505
|
+
'width' => (pdf.margin_box.width / ww).to_i - 1,
|
506
|
+
'height' => (pdf.margin_box.height / hh).to_i - 1,
|
507
|
+
}
|
508
|
+
)
|
509
509
|
|
510
510
|
|
511
511
|
begin
|
512
512
|
# See if it is possible to pack several map sections (sections) into
|
513
513
|
# a single print page.
|
514
|
-
num = pack_sections( pdf_options['width'] + 2,
|
514
|
+
num = pack_sections( pdf_options['width'] + 2,
|
515
515
|
pdf_options['height'] + 2 )
|
516
516
|
pdf_draw_sections(pdf, pdf_options)
|
517
517
|
if pdffile !~ /\.pdf$/
|
518
|
-
|
518
|
+
pdffile << ".pdf"
|
519
519
|
end
|
520
520
|
status "Exporting PDF file '#{pdffile}'"
|
521
521
|
pdf.render_file pdffile
|
data/maps/CityOfSecrets.map
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ifmapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Garramuno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -51,25 +51,25 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.6.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: prawn
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
59
|
+
version: 1.0.0
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.
|
62
|
+
version: 1.0.0
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.
|
69
|
+
version: 1.0.0
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 1.
|
72
|
+
version: 1.0.0
|
73
73
|
description: " Interactive Fiction Mapping Tool.\n"
|
74
74
|
email: ggarra13@gmail.com
|
75
75
|
executables:
|