Class: GridGenerator::Skewb::LeftGrid

Inherits:
SkewbGrid
  • Object
show all
Defined in:
lib/grid_generator/skewb/left_grid.rb

Constant Summary

Constants inherited from SkewbGrid

SkewbGrid::COLOURS

Instance Attribute Summary

Attributes inherited from SkewbGrid

#elements, #units, #x, #y

Instance Method Summary collapse

Methods inherited from SkewbGrid

#base_shape, #base_shape_style, #build_element, #element_shapes, #initialize, #side_size, #to_svg

Constructor Details

This class inherits a constructor from GridGenerator::Skewb::SkewbGrid

Instance Method Details

#columnsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/grid_generator/skewb/left_grid.rb', line 37

def columns
  Array.new(side_size) do |i|
    a = Matrix.column_vector([
      x + (2*i)*units,
      y + (-1*i+2)*units,
    ])

    b = Matrix.column_vector([
      x + (i+1)*2*units,
      y + (-1*i+5)*units
    ])

    GridGenerator::BaseLine.new(a: a, b: b) 
  end
end

#factory_classObject



8
9
10
# File 'lib/grid_generator/skewb/left_grid.rb', line 8

def factory_class
  GridGenerator::Skewb::LeftElementFactory
end

#pointsObject



12
13
14
15
16
17
18
19
# File 'lib/grid_generator/skewb/left_grid.rb', line 12

def points
  [
    Matrix.column_vector([ x, y ]),
    Matrix.column_vector([ x + side_size*2*units, y + side_size*units ]),
    Matrix.column_vector([ x + side_size*2*units, y + side_size*3*units ]),
    Matrix.column_vector([ x, y + side_size*2*units ])
  ]
end

#rowsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/grid_generator/skewb/left_grid.rb', line 21

def rows
  Array.new(side_size) do |i|
    a = Matrix.column_vector([
      x + (2*i)*units,
      y + (3*i+2)*units,
    ])

    b = Matrix.column_vector([
      x + (2*i+2)*units,
      y + (3*i+1)*units
    ])

    GridGenerator::BaseLine.new(a: a, b: b) 
  end
end