Class: GridGenerator::Skewb::RightGrid

Inherits:
SkewbGrid
  • Object
show all
Defined in:
lib/grid_generator/skewb/right_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



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

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

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

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

#factory_classObject



9
10
11
# File 'lib/grid_generator/skewb/right_grid.rb', line 9

def factory_class
  GridGenerator::Skewb::RightElementFactory
end

#pointsObject



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

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

#rowsObject



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

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

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

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