astromapper 1.0.5 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5273245b8abdf862d99dd54fdfd64e35d96ff1f2
4
- data.tar.gz: 5dbe72dbc3c3af5ee68adb9707379267ae91906e
3
+ metadata.gz: 6a9cfe24acc8a2bc95bdd68bb086bea417e6a88f
4
+ data.tar.gz: 8112420708e36c7b322d75fe396e8c70739db970
5
5
  SHA512:
6
- metadata.gz: e6ce1000f285d0af740dbd56ebb28fcbf4f84075e6b644c1fd11bebf32c00996930ef7fb67a9189bdbe5c431d3603524fb4da911af63940317c097097c38fa1c
7
- data.tar.gz: b474772f11906d013f6466e3db164966f39df072971779bb4836a16a27725a05937fd423905810ac9b5ee168a2000643cd87f4ea4e861dda438ac9a3b6e163ea
6
+ metadata.gz: 32fc9e5f9f16656b4bcf83803136dd4b1ecbdd3a2cd9c1eabf93fe57b1cfd5e745c271d575c1417f34735cad5ab6469e578511c8b13234c7369b7cdb55d8491a
7
+ data.tar.gz: 37f9179db14c9c620c3b1f9b73b1733679df91a424232b15d92299863e1cdcee3ca9db9bb7006a415bb334d19cb7df063156d6582b8b69159510744c9739cb5f
@@ -17,53 +17,7 @@ module Astromapper
17
17
  @zones = []
18
18
  @volumes = []
19
19
  @name = config['name']
20
- # puts "Height: #{@height}; Width: #{@width}"
21
20
 
22
- base03 = config['colors']['base03'] || '#002b36'
23
- base02 = config['colors']['base02'] || '#073642'
24
- base01 = config['colors']['base01'] || '#586e75'
25
- base00 = config['colors']['base03'] || '#657b83'
26
- base0 = config['colors']['base0'] || '#839496'
27
- base1 = config['colors']['base1'] || '#93a1a1'
28
- base2 = config['colors']['base2'] || '#eee8d5'
29
- base3 = config['colors']['base3'] || '#fdf6e3'
30
- yellow = config['colors']['yellow'] || '#b58900'
31
- orange = config['colors']['orange'] || '#cb4b16'
32
- red = config['colors']['red'] || '#dc322f'
33
- magenta = config['colors']['magenta'] || '#d33682'
34
- violet = config['colors']['violet'] || '#6c71c4'
35
- blue = config['colors']['blue'] || '#268bd2'
36
- cyan = config['colors']['cyan'] || '#2aa198'
37
- green = config['colors']['green'] || '#859900'
38
- white = config['colors']['white'] || '#FFFFFF'
39
- black = config['colors']['black'] || '#222222'
40
-
41
- @theme = {
42
- 'dark' => {
43
- :background => base03,
44
- :zone => {'AZ' => yellow, 'RZ' => red},
45
- :hex => base1,
46
- :hex_id => base2,
47
- :world_text => base2,
48
- :black => base3,
49
- :base02 => base2,
50
- :base1 => base01,
51
- :white => white,
52
- :tract_id => base01
53
- },
54
- 'lite' => {
55
- :background => white,
56
- :zone => {'AZ' => yellow, 'RZ' => red},
57
- :hex => base1,
58
- :hex_id => base01,
59
- :world_text => base01,
60
- :black => black,
61
- :base02 => base02,
62
- :base1 => base1,
63
- :white => white,
64
- :tract_id => base2
65
- }
66
- }
67
21
  theme = (%w{lite dark}.include?(config['svg_theme'])) ? config['svg_theme'] : 'lite'
68
22
  @color = @theme[theme]
69
23
  @hex = {
@@ -71,47 +25,6 @@ module Astromapper
71
25
  :side_w => (@side / 2).tweak,
72
26
  :width => @side
73
27
  }
74
- # @style = {
75
- # :circle => "fill='#{@color[:black]}' stroke='#{@color[:white]}' stroke-width='1'",
76
- # :polyline => "fill='none'",
77
- # :polygon => "fill='#{@color[:black]}' stroke='none' stroke-width='1'",
78
- # :ellipse => "fill='none' stroke='#{@color[:base02]}' stroke-width='1'",
79
- # :Belt => "stroke='#{@color[:white]}' stroke-width='1'",
80
- # :AZ_zone => "fill='none' stroke='#{@color[:zone]['AZ']}' stroke-width='3' stroke-dasharray='5%,5%'",
81
- # :RZ_zone => "fill='none' stroke='#{@color[:zone]['RZ']}' stroke-width='3'",
82
- # :Planet => "fill='#{@color[:black]}' stroke='#{@color[:black]}' stroke-width='1'",
83
- # :Desert => "fill='none' stroke='#{@color[:black]}' stroke-width='2'",
84
- # :Frame => "fill='none' stroke='#{@color[:black]}' stroke-width='4'",
85
- # :Tract => "fill='none' stroke='#{@color[:hex]}' stroke-width='1'",
86
- # :Hexgrid => "fill='none' stroke='#{@color[:hex]}' stroke-width='1'",
87
- # :Name => "text-anchor='middle' font-size='#{@side/5}px' fill='#{@color[:world_text]}' font-family='Verdana'",
88
- # :symbol => "text-anchor='middle' font-size='#{@side/2.5}px' fill='#{@color[:black]}' font-family='Verdana'",
89
- # :Spaceport => "text-anchor='middle' font-size='#{@side/3}px' fill='#{@color[:world_text]}' font-family='Verdana'",
90
- # :TractID => "text-anchor='middle' font-size='#{@side*3}px' fill='#{@color[:tract_id]}' font-family='Verdana'",
91
- # :VolumeId => "text-anchor='middle' font-size='#{@side/5}px' fill='#{@color[:hex_id]}' font-family='Verdana'",
92
- # :rect => "fill='#{@color[:background]}'"
93
- # }
94
- @style = {
95
- :circle => "fill='#{@color[:black]}' stroke='#{@color[:white]}' stroke-width='1'",
96
- :polyline => "fill='none'",
97
- :polygon => "fill='#{@color[:black]}' stroke='none' stroke-width='1'",
98
- :ellipse => "fill='none' stroke='#{@color[:base02]}' stroke-width='1'",
99
- :Belt => "stroke='#{@color[:white]}' stroke-width='1'",
100
- :AZ_zone => "class='lowsec'",
101
- :RZ_zone => "class='lowsec'",
102
- :Planet => "",
103
- :Desert => "",
104
- :Frame => "",
105
- :Tract => "",
106
- :Hexgrid => "",
107
- :Name => "",
108
- :symbol => "",
109
- :Spaceport => "",
110
- :TractID => "",
111
- :VolumeId => "",
112
- :rect => "fill='#{@color[:background]}'"
113
- }
114
- @style[:UWP] = @style[:Name]
115
28
  end
116
29
  def from_file
117
30
  File.open(@source_filename,'r').readlines.each { |line| @volumes << line if /^\d{4}/.match(line) }
@@ -150,10 +63,10 @@ module Astromapper
150
63
  fill: #eed;
151
64
  font: 120px sans-serif;
152
65
  }
153
- text.sector-name {
66
+ text.namestamp {
154
67
  font-size: 13px;
155
68
  }
156
- text.scout {
69
+ text.symbol {
157
70
  font-size: 14px;
158
71
  fill: #222;
159
72
  }
@@ -191,7 +104,7 @@ module Astromapper
191
104
  stroke-dasharray: 3,6;
192
105
  }
193
106
  </style>
194
- <rect #{@style[:rect]} width='#{@width}' height='#{@height}' />
107
+ <rect width='#{@width}' height='#{@height}' />
195
108
  EOS
196
109
  end
197
110
  def center_of(locx)
@@ -234,12 +147,12 @@ module Astromapper
234
147
 
235
148
  output = "<!-- Volume: #{volume.strip.gsub(/\t/,' // ')} -->\n"
236
149
  output += (size == '0') ? draw_belt(c) : draw_planet(c,uwp)
237
- output += " <text #{@style[:Spaceport]} x='#{c[0]}' y='#{(c[1] + @side / 2).tweak}'>#{spaceport.strip}</text>\n"
238
- output += " <text #{@style[:UWP]} x='#{c[0]}' y='#{(c[1]+(@side/1.3)).tweak}'>#{uwp.strip}</text>\n"
239
- output += " <text #{@style[:Name]} x='#{c[0]}' y='#{(c[1]-(@side/2.1)).tweak}'>#{name.strip}</text>\n"
150
+ output += " <text class='spaceport' x='#{c[0]}' y='#{(c[1] + @side / 2).tweak}'>#{spaceport.strip}</text>\n"
151
+ output += " <text x='#{c[0]}' y='#{(c[1]+(@side/1.3)).tweak}'>#{uwp.strip}</text>\n"
152
+ output += " <text x='#{c[0]}' y='#{(c[1]-(@side/2.1)).tweak}'>#{name.strip}</text>\n"
240
153
  unless zone == '..'
241
154
  style = zone + '_zone'
242
- output += " <path #{@style[style.to_sym]} d='M #{c[0] - curve/2;} #{c[1] - (curve/1.4)} a #{curve} #{curve} 0 1 0 20 0' />\n"
155
+ output += " <path d='M #{c[0] - curve/2;} #{c[1] - (curve/1.4)} a #{curve} #{curve} 0 1 0 20 0' />\n"
243
156
  end
244
157
  output += navy_base(c) if nsg.include?('N')
245
158
  output += scout_base(c) if nsg.include?('S')
@@ -256,7 +169,7 @@ module Astromapper
256
169
  x = (c[0]+(@side/1.8)).tweak + 2
257
170
  y = (c[1]-(@side/3)).tweak + 3
258
171
  stars.split('/').each do |star|
259
- output += " <text #{@style[:Name]} x='#{x}' y='#{y}'>#{star[0..1].strip}</text>\n"
172
+ output += " <text x='#{x}' y='#{y}'>#{star[0..1].strip}</text>\n"
260
173
  x += 3
261
174
  y += 7
262
175
  end
@@ -264,21 +177,21 @@ module Astromapper
264
177
  end
265
178
  def draw_planet(c,w)
266
179
  k = (w[3] == '0') ? 'Desert' : 'Planet'
267
- " <circle #{@style[:circle]} cx='#{c[0]}' cy='#{c[1]}' r='#{@side/7}' />\n"
180
+ " <circle class='planet' cx='#{c[0]}' cy='#{c[1]}' r='#{@side/7}' />\n"
268
181
  end
269
182
  def draw_belt(c)
270
183
  output = " <g stroke='none' fill='none'>\n"
271
184
  7.times do
272
185
  x = c[0] + Random.rand(@side/3) - @side/6
273
186
  y = c[1] + Random.rand(@side/3) - @side/6
274
- output += " <circle #{@style[:Belt]} cx='#{x.tweak}' cy='#{y.tweak}' r='#{(@side/15).tweak}' />\n"
187
+ output += " <circle class='belt' cx='#{x.tweak}' cy='#{y.tweak}' r='#{(@side/15).tweak}' />\n"
275
188
  end
276
189
  output + " </g>\n"
277
190
  end
278
191
  def frame(k='Frame')
279
192
  style = k.to_sym
280
193
  z = 0; w = @width - 0; h = @height - z;
281
- " <polyline #{@style[style]} points='#{z},#{z} #{w},#{z} #{w},#{h} #{z},#{h} #{z},#{z}' />"
194
+ " <polyline class='frame' points='#{z},#{z} #{w},#{z} #{w},#{h} #{z},#{h} #{z},#{z}' />"
282
195
  end
283
196
  def tract_marks
284
197
  height = (@height / 4).floor
@@ -292,8 +205,8 @@ module Astromapper
292
205
  w2 = 0
293
206
  4.times do |c|
294
207
  w1 = w2; w2 += (width - [-4,4,5,-4][c])
295
- output += " <text #{@style[:TractID]} x='#{w1 + 70}' y='#{h1 + 110}'>#{letters.shift}</text>\n"
296
- output += " <polyline #{@style[:Tract]} points='#{w1},#{h1} #{w2},#{h1} #{w2},#{h2} #{w1},#{h2} #{w1},#{h1}' />\n"
208
+ output += " <text class='tract' x='#{w1 + 70}' y='#{h1 + 110}'>#{letters.shift}</text>\n"
209
+ output += " <polyline class='tract' points='#{w1},#{h1} #{w2},#{h1} #{w2},#{h2} #{w1},#{h2} #{w1},#{h1}' />\n"
297
210
  # raise output
298
211
  end
299
212
  end
@@ -306,42 +219,42 @@ module Astromapper
306
219
  (@columns+1).times do |c|
307
220
  x = @side + ((c-1) * @side * 1.5)
308
221
  y = (c % 2 == 1) ? (r-1) * @side * @factor + (0.2 * @side) : (r-1) * @side * @factor + @hex[:side_h]+ (0.2 * @side)
309
- output += "<text #{@style[:VolumeId]} x='#{x.tweak}' y='#{y.tweak}'>%02d%02d</text>\n" % [c,r]
222
+ output += "<text class='volume-id' x='#{x.tweak}' y='#{y.tweak}'>%02d%02d</text>\n" % [c,r]
310
223
  end
311
224
  end
312
225
  output
313
226
  end
314
227
  def polygon(x, y, sx, sy, sides=4)
315
228
  polygon = star_coords(sx, sy, sides).map { |c| "#{x + c[0]},#{y.tweak+c[1]}" }
316
- " <polygon #{@style[:polygon]} points='#{polygon.join(' ')}' />\n"
229
+ " <polygon points='#{polygon.join(' ')}' />\n"
317
230
  end
318
231
  def gas_giant(c)
319
232
  x = (c[0]+(@side/1.8)).tweak; y = (c[1]+(@side/3)).tweak;
320
233
  return<<-GIANT
321
- <g><!-- Has Gas Giant -->
322
- <ellipse #{@style[:ellipse]} cx='#{x}' cy='#{y}' rx='#{(@side/(@mark * 0.5)).tweak}' ry='#{(@side/@mark * 0.3).tweak}' />
323
- <circle #{@style[:circle]} cx='#{x}' cy='#{y}' r='#{(@side/(@mark * 1.2)).tweak}' />
234
+ <g class='gas-giant'><!-- Has Gas Giant -->
235
+ <ellipse cx='#{x}' cy='#{y}' rx='#{(@side/(@mark * 0.5)).tweak}' ry='#{(@side/@mark * 0.3).tweak}' />
236
+ <circle cx='#{x}' cy='#{y}' r='#{(@side/(@mark * 1.2)).tweak}' />
324
237
  </g>
325
238
  GIANT
326
239
  end
327
240
  def pirates(c);
328
- return "<!-- Pirates --><text #{@style[:symbol]} x='#{c[0]-(@side/3.1)}' y='#{c[1]+(@side/7)}'>\u2620</text>\n"
241
+ return "<!-- Pirates --><text class='symbol' x='#{c[0]-(@side/3.1)}' y='#{c[1]+(@side/7)}'>\u2620</text>\n"
329
242
  end
330
243
  def consulate(c);
331
- return "<!-- Consulate --><text #{@style[:symbol]} x='#{c[0]-(@side/1.5)}' y='#{c[1]+(@side/7)}'>\u2691</text>\n"
244
+ return "<!-- Consulate --><text class='symbol' x='#{c[0]-(@side/1.5)}' y='#{c[1]+(@side/7)}'>\u2691</text>\n"
332
245
  end
333
246
  def scout_base(c);
334
- return "<!-- Scout Base --><text #{@style[:symbol]} x='#{c[0]-(@side/1.8)}' y='#{c[1]+(@side/2.4)}'>\u269C</text>\n"
247
+ return "<!-- Scout Base --><text class='symbol' x='#{c[0]-(@side/1.8)}' y='#{c[1]+(@side/2.4)}'>\u269C</text>\n"
335
248
  '<!-- SB -->' + polygon(c[0]-(@side/1.8),c[1]+(@side/3.7), @side/(@mark/2), @side/@mark, 3);
336
249
  end
337
250
  def navy_base(c);
338
- return "<!-- Navy Base --><text #{@style[:symbol]} x='#{c[0]-(@side/1.8)}' y='#{c[1]-(@side/6)}'>\u2693</text>\n"
251
+ return "<!-- Navy Base --><text class='symbol' x='#{c[0]-(@side/1.8)}' y='#{c[1]-(@side/6)}'>\u2693</text>\n"
339
252
  '<!-- NB -->' +polygon(c[0]-(@side/1.8), c[1]-(@side/3.7), @side/(@mark/2), @side/@mark, 5);
340
253
  end
341
254
  def hex_grid; (@rows * 3 + 2).times.map { |j| hex_row((j/2).floor, (j % 2 != 0)) };
342
255
  end
343
256
  def namestamp
344
- return "<text text-anchor='left' font-size='30px' fill='#8A9DD1' font-family='Verdana' x='30' y='2800'>#{@name}</text>"
257
+ return "<text class='namestamp' x='30' y='2800'>#{@name}</text>"
345
258
  end
346
259
  def hex_row(row, top=false)
347
260
  ly = (row * 2 * @hex[:side_h]) + @hex[:side_h]
@@ -369,7 +282,7 @@ module Astromapper
369
282
  x += @hex[:side_w]
370
283
  y = (top) ? y - @hex[:side_h] : y + @hex[:side_h]
371
284
  points << "#{x.tweak},#{y.tweak}"
372
- " <polyline #{@style[:Hexgrid]} points='#{points.join(' ')}' />"
285
+ " <polyline points='#{points.join(' ')}' />"
373
286
  end
374
287
  end
375
288
  end
@@ -1,3 +1,3 @@
1
1
  module Astromapper
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astromapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Merovex