Class: Amaze::Shape::Hexagon
Instance Attribute Summary
Attributes inherited from Amaze::Shape
#size
Instance Method Summary
collapse
#create_mask, #initialize, #mask
Constructor Details
This class inherits a constructor from Amaze::Shape
Instance Method Details
#build_mask ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/amaze/shape/hexagon.rb', line 4
def build_mask
(0...size).each do |row|
on = size * 2 + 1 + row * 2
off = (columns - on) / 2
line_map = Array.new(off, false) + Array.new(on, true) + Array.new(off, false)
line_map.each_with_index do |switch, i|
mask[row, i] = switch
mask[rows-row-1,i] = switch
end
end
end
|
#columns ⇒ Object
23
24
25
|
# File 'lib/amaze/shape/hexagon.rb', line 23
def columns
(size-1) * 4 + 3 + offset * 2
end
|
#offset ⇒ Object
27
28
29
|
# File 'lib/amaze/shape/hexagon.rb', line 27
def offset
size.even? ? 0 : 1
end
|
#rows ⇒ Object
19
20
21
|
# File 'lib/amaze/shape/hexagon.rb', line 19
def rows
size * 2
end
|