Sha256: 8fb783943121a05a0ed6bb427780f8d3fdec070452e9345e5c5f9a76d7b8c7da

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

require_relative '../line'
require_relative '../base_element'
require_relative 'skewb_grid'
require_relative 'top_element_factory'

module GridGenerator
  module Skewb
    class TopSkewbGrid < Skewb::SkewbGrid
      def factory_class
        GridGenerator::Skewb::TopElementFactory
      end
  
      def border_points
        [
          [ x + side_size*2*units, y ],
          [ x + side_size*4*units, y + side_size*units ],
          [ x + side_size*2*units, y + side_size*2*units ],
          [ x, y + side_size*units ]
        ]
      end 
  
      def rows
        Array.new(side_size) do |i|
          a = Matrix.column_vector([
            x + 2*units,
            y + (2*i+1)*units,
          ])

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

          GridGenerator::Line.new(a: a, b: b) 
        end
      end
  
      def columns
        Array.new(side_size) do |i|
          a = Matrix.column_vector([
            x + (4*i+2)*units,
            y + units,
          ])

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

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
grid_generator-0.3.0 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.24 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.23 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.22 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.21 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.20 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.19 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.18 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.17 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.16 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.15 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.14 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.13 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.12 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.11 lib/grid_generator/skewb/top_skewb_grid.rb
grid_generator-0.2.10 lib/grid_generator/skewb/top_skewb_grid.rb