Method: Astromapper::Svg#hex_row

Defined in:
lib/astromapper/svg.rb

#hex_row(row, top = false) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/astromapper/svg.rb', line 339

def hex_row(row, top=false)
  ly = (row * 2 * @hex[:side_h]) + @hex[:side_h]
  points = []
  x = 0; y = 0
  (@columns/2).ceil.times do |j|
    x = j * @side * 3
    y = ly
    points << "#{x.to_i},#{y.to_i}"

    x += @hex[:side_w]
    y = (top) ? y - @hex[:side_h] : y + @hex[:side_h]
    points << "#{x.to_i},#{y.to_i}"

    x += @hex[:width]
    points << "#{x.to_i},#{y.to_i}"

    x += @hex[:side_w]
    y = (top) ? y + @hex[:side_h] : y - @hex[:side_h]
    points << "#{x.to_i},#{y.to_i}"

    x += @hex[:width]
    points << "#{x.to_i},#{y.to_i}"
  end
  x += @hex[:side_w]
  y = (top) ? y - @hex[:side_h] : y + @hex[:side_h]
  points << "#{x.to_i},#{y.to_i}"
  "    <polyline points='#{points.join(' ')}' />"
end