grid_generator 0.2.24 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile.lock +1 -1
 - data/lib/grid_generator/base_element.rb +9 -0
 - data/lib/grid_generator/cubic/bordered_grid.rb +23 -0
 - data/lib/grid_generator/cubic/facing_grid.rb +23 -0
 - data/lib/grid_generator/cubic/grid.rb +23 -0
 - data/lib/grid_generator/cubic/iso_view.rb +7 -0
 - data/lib/grid_generator/face_parser.rb +1 -1
 - data/lib/grid_generator/megaminx/face_projection.rb +35 -0
 - data/lib/grid_generator/pyraminx/face.rb +27 -0
 - data/lib/grid_generator/skewb/left_skewb_grid.rb +25 -0
 - data/lib/grid_generator/skewb/right_skewb_grid.rb +25 -0
 - data/lib/grid_generator/skewb/top_skewb_grid.rb +25 -0
 - data/lib/grid_generator/square_one/face.rb +19 -0
 - data/lib/grid_generator/version.rb +1 -1
 - data/lib/grid_generator.rb +0 -25
 - metadata +2 -11
 - data/lib/grid_generator/arrows/arrow.rb +0 -29
 - data/lib/grid_generator/arrows/diagonal_down_arrow.rb +0 -65
 - data/lib/grid_generator/arrows/diagonal_up_arrow.rb +0 -66
 - data/lib/grid_generator/arrows/horizontal_arrow.rb +0 -66
 - data/lib/grid_generator/arrows/vertical_arrow.rb +0 -66
 - data/lib/grid_generator/megaminx/common.rb +0 -95
 - data/lib/grid_generator/megaminx/element_factory.rb +0 -52
 - data/lib/grid_generator/megaminx/face.rb +0 -79
 - data/lib/grid_generator/megaminx/front_face.rb +0 -12
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f26be22e443d706a070b3610b275de01024997c550ed65d106afc6193e8fe0f3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 41ee0e26215d6d6296907a735c93b0a832b9418fd2d1cdf0121404b3db6e8b7c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6eedfb3bdc00baa6eec0b8173afb35efdafb2e5583a354d128f9e078ddd26e768785bf0a8a3f095b830d8b9f4fc93c131c4191c7c33c779bceb826078a1bdda1
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f9029ee7f2f8c80e72e72a83f7792f5b941075f3d0e074ee8704b8c84cf3342a5c354e006b07c6e7c0e0b486c3702f8c2d89c526a319c0e9a0ce4b4a116355b6
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
| 
         @@ -1,5 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       2 
2 
     | 
    
         
             
              class BaseElement
         
     | 
| 
      
 3 
     | 
    
         
            +
                COLOURS = {
         
     | 
| 
      
 4 
     | 
    
         
            +
                  fill: "#d0d0d0",
         
     | 
| 
      
 5 
     | 
    
         
            +
                  stroke: "#404040"
         
     | 
| 
      
 6 
     | 
    
         
            +
                }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       3 
8 
     | 
    
         
             
                def initialize(points:, colour: , opacity: 1)
         
     | 
| 
       4 
9 
     | 
    
         
             
                  @points = points
         
     | 
| 
       5 
10 
     | 
    
         
             
                  @colour = colour
         
     | 
| 
         @@ -26,5 +31,9 @@ module GridGenerator 
     | 
|
| 
       26 
31 
     | 
    
         
             
                    "opacity" => opacity
         
     | 
| 
       27 
32 
     | 
    
         
             
                  }
         
     | 
| 
       28 
33 
     | 
    
         
             
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                def to_svg
         
     | 
| 
      
 36 
     | 
    
         
            +
                  "<polygon points=\"#{points_string}}\" style=\"fill:#{colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{opacity}\" />"
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
       29 
38 
     | 
    
         
             
              end
         
     | 
| 
       30 
39 
     | 
    
         
             
            end
         
     | 
| 
         @@ -6,6 +6,11 @@ require_relative 'facing_square_factory' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       7 
7 
     | 
    
         
             
              module Cubic
         
     | 
| 
       8 
8 
     | 
    
         
             
                class BorderedGrid
         
     | 
| 
      
 9 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       9 
14 
     | 
    
         
             
                  def initialize(x:, y:, units:, squares: )
         
     | 
| 
       10 
15 
     | 
    
         
             
                    @x, @y = x, y
         
     | 
| 
       11 
16 
     | 
    
         
             
                    @units = units
         
     | 
| 
         @@ -136,6 +141,24 @@ module GridGenerator 
     | 
|
| 
       136 
141 
     | 
    
         
             
                      "element_shapes" => element_shapes.map(&:as_json)
         
     | 
| 
       137 
142 
     | 
    
         
             
                    }
         
     | 
| 
       138 
143 
     | 
    
         
             
                  end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 146 
     | 
    
         
            +
                    output = "<polygon points=\"#{points_string}\" style=\"fill:#{COLOURS[:fill]};stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                    for row in rows do
         
     | 
| 
      
 149 
     | 
    
         
            +
                      output += "<line x1=\"#{row.x1}\" y1=\"#{row.y1}\" x2=\"#{row.x2}\" y2=\"#{row.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 150 
     | 
    
         
            +
                    end
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                    for col in columns do
         
     | 
| 
      
 153 
     | 
    
         
            +
                      output += "<line x1=\"#{col.x1}\" y1=\"#{col.y1}\" x2=\"#{col.x2}\" y2=\"#{col.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 154 
     | 
    
         
            +
                    end
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                    for shape in element_shapes do
         
     | 
| 
      
 157 
     | 
    
         
            +
                      output += "<polygon points=\"#{shape.points_string}\" style=\"fill:#{shape.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{shape.opacity}\" />"
         
     | 
| 
      
 158 
     | 
    
         
            +
                    end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                    output
         
     | 
| 
      
 161 
     | 
    
         
            +
                  end
         
     | 
| 
       139 
162 
     | 
    
         
             
                end
         
     | 
| 
       140 
163 
     | 
    
         
             
              end
         
     | 
| 
       141 
164 
     | 
    
         
             
            end
         
     | 
| 
         @@ -6,6 +6,11 @@ require_relative 'facing_square_factory' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       7 
7 
     | 
    
         
             
              module Cubic
         
     | 
| 
       8 
8 
     | 
    
         
             
                class FacingGrid
         
     | 
| 
      
 9 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       9 
14 
     | 
    
         
             
                  def initialize(x:, y:, units:, squares: )
         
     | 
| 
       10 
15 
     | 
    
         
             
                    @x, @y = x, y
         
     | 
| 
       11 
16 
     | 
    
         
             
                    @units = units
         
     | 
| 
         @@ -116,6 +121,24 @@ module GridGenerator 
     | 
|
| 
       116 
121 
     | 
    
         
             
                      "element_shapes" => element_shapes.map(&:as_json)
         
     | 
| 
       117 
122 
     | 
    
         
             
                    }
         
     | 
| 
       118 
123 
     | 
    
         
             
                  end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 126 
     | 
    
         
            +
                    output = "<polygon points=\"#{points_string}\" style=\"fill:#{COLOURS[:fill]};stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 127 
     | 
    
         
            +
             
         
     | 
| 
      
 128 
     | 
    
         
            +
                    for row in rows do
         
     | 
| 
      
 129 
     | 
    
         
            +
                      output += "<line x1=\"#{row.x1}\" y1=\"#{row.y1}\" x2=\"#{row.x2}\" y2=\"#{row.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 130 
     | 
    
         
            +
                    end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
         
     | 
| 
      
 132 
     | 
    
         
            +
                    for col in columns do
         
     | 
| 
      
 133 
     | 
    
         
            +
                      output += "<line x1=\"#{col.x1}\" y1=\"#{col.y1}\" x2=\"#{col.x2}\" y2=\"#{col.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 134 
     | 
    
         
            +
                    end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
         
     | 
| 
      
 136 
     | 
    
         
            +
                    for shape in element_shapes do
         
     | 
| 
      
 137 
     | 
    
         
            +
                      output += "<polygon points=\"#{shape.points_string}\" style=\"fill:#{shape.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{shape.opacity}\" />"
         
     | 
| 
      
 138 
     | 
    
         
            +
                    end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                    output
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
       119 
142 
     | 
    
         
             
                end
         
     | 
| 
       120 
143 
     | 
    
         
             
              end
         
     | 
| 
       121 
144 
     | 
    
         
             
            end
         
     | 
| 
         @@ -4,6 +4,11 @@ require_relative '../line' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       5 
5 
     | 
    
         
             
              module Cubic
         
     | 
| 
       6 
6 
     | 
    
         
             
                class Grid
         
     | 
| 
      
 7 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 9 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       7 
12 
     | 
    
         
             
                  def initialize(x:, y:, units: , squares: ) 
         
     | 
| 
       8 
13 
     | 
    
         
             
                    @x, @y = x, y
         
     | 
| 
       9 
14 
     | 
    
         
             
                    @units = units
         
     | 
| 
         @@ -161,6 +166,24 @@ module GridGenerator 
     | 
|
| 
       161 
166 
     | 
    
         
             
                      "element_shapes" => element_shapes.map(&:as_json)
         
     | 
| 
       162 
167 
     | 
    
         
             
                    }
         
     | 
| 
       163 
168 
     | 
    
         
             
                  end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 171 
     | 
    
         
            +
                    output = "<polygon points=\"#{points_string}\" style=\"fill:#{COLOURS[:fill]};stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                    for row in rows do
         
     | 
| 
      
 174 
     | 
    
         
            +
                      output += "<line x1=\"#{row.x1}\" y1=\"#{row.y1}\" x2=\"#{row.x2}\" y2=\"#{row.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 175 
     | 
    
         
            +
                    end
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                    for col in columns do
         
     | 
| 
      
 178 
     | 
    
         
            +
                      output += "<line x1=\"#{col.x1}\" y1=\"#{col.y1}\" x2=\"#{col.x2}\" y2=\"#{col.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 179 
     | 
    
         
            +
                    end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                    for shape in element_shapes do
         
     | 
| 
      
 182 
     | 
    
         
            +
                      output += "<polygon points=\"#{shape.points_string}\" style=\"fill:#{shape.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{shape.opacity}\" />"
         
     | 
| 
      
 183 
     | 
    
         
            +
                    end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                    output
         
     | 
| 
      
 186 
     | 
    
         
            +
                  end
         
     | 
| 
       164 
187 
     | 
    
         
             
                end
         
     | 
| 
       165 
188 
     | 
    
         
             
              end
         
     | 
| 
       166 
189 
     | 
    
         
             
            end
         
     | 
| 
         @@ -7,6 +7,10 @@ require_relative 'face_element_factory' 
     | 
|
| 
       7 
7 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       8 
8 
     | 
    
         
             
              module Megaminx
         
     | 
| 
       9 
9 
     | 
    
         
             
                class FaceProjection
         
     | 
| 
      
 10 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 11 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 12 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  }
         
     | 
| 
       10 
14 
     | 
    
         
             
                  # units 30 - pentagon 90 - megaminx - 150
         
     | 
| 
       11 
15 
     | 
    
         
             
                  # units * 5 
         
     | 
| 
       12 
16 
     | 
    
         
             
                  def initialize(x:, y:, units:, front_face_elements: "", top_right_face_elements: "", right_face_elements: "", down_face_elements: "", left_face_elements: "", top_left_face_elements: "", rotation_offset: 0)
         
     | 
| 
         @@ -205,6 +209,37 @@ module GridGenerator 
     | 
|
| 
       205 
209 
     | 
    
         
             
                      end.compact
         
     | 
| 
       206 
210 
     | 
    
         
             
                    end
         
     | 
| 
       207 
211 
     | 
    
         
             
                  end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 214 
     | 
    
         
            +
                    output = "<polygon points=\"#{ decagon_points_string }\" style=\"fill:#{ COLOURS[:fill] };stroke:#{ COLOURS[:stroke] };stroke-width:1\" />"
         
     | 
| 
      
 215 
     | 
    
         
            +
                    output += "<polygon points=\"#{ pentagon_points_string }\" style=\"fill:none;stroke:#{ COLOURS[:stroke] };stroke-width:1\" />"
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
                    for line in connecting_lines do
         
     | 
| 
      
 218 
     | 
    
         
            +
                      output += "<line x1=\"#{line.x1}\" y1=\"#{line.y1}\" x2=\"#{line.x2}\" y2=\"#{line.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 219 
     | 
    
         
            +
                    end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                    for line in front_face_lines do
         
     | 
| 
      
 222 
     | 
    
         
            +
                      output += "<line x1=\"#{line.x1}\" y1=\"#{line.y1}\" x2=\"#{line.x2}\" y2=\"#{line.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 223 
     | 
    
         
            +
                    end
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
                    for face in outside_face_lines do
         
     | 
| 
      
 226 
     | 
    
         
            +
                      for line in face do
         
     | 
| 
      
 227 
     | 
    
         
            +
                        output += "<line x1=\"#{line.x1}\" y1=\"#{line.y1}\" x2=\"#{line.x2}\" y2=\"#{line.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 228 
     | 
    
         
            +
                      end
         
     | 
| 
      
 229 
     | 
    
         
            +
                    end
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
                    for shape in front_face_element_shapes do
         
     | 
| 
      
 232 
     | 
    
         
            +
                      output += "<polygon points=\"#{shape.points_string}\" style=\"fill:#{shape.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{shape.opacity}\" />"
         
     | 
| 
      
 233 
     | 
    
         
            +
                    end
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
                    for face in outside_face_element_shapes do
         
     | 
| 
      
 236 
     | 
    
         
            +
                      for shape in face do
         
     | 
| 
      
 237 
     | 
    
         
            +
                        output += "<polygon points=\"#{shape.points_string}\" style=\"fill:#{shape.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{shape.opacity}\" />"
         
     | 
| 
      
 238 
     | 
    
         
            +
                      end
         
     | 
| 
      
 239 
     | 
    
         
            +
                    end
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
                    output
         
     | 
| 
      
 242 
     | 
    
         
            +
                  end
         
     | 
| 
       208 
243 
     | 
    
         
             
                end
         
     | 
| 
       209 
244 
     | 
    
         
             
              end
         
     | 
| 
       210 
245 
     | 
    
         
             
            end
         
     | 
| 
         @@ -9,6 +9,11 @@ module GridGenerator 
     | 
|
| 
       9 
9 
     | 
    
         
             
                # * * *
         
     | 
| 
       10 
10 
     | 
    
         
             
                # * * * * * 
         
     | 
| 
       11 
11 
     | 
    
         
             
                class Face
         
     | 
| 
      
 12 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 13 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 14 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       12 
17 
     | 
    
         
             
                  def initialize(x:, y:, units:, elements:, vertical_scale: 1, rotation_angle: 0)
         
     | 
| 
       13 
18 
     | 
    
         
             
                    @x, @y = x, y
         
     | 
| 
       14 
19 
     | 
    
         
             
                    @units = units
         
     | 
| 
         @@ -190,6 +195,28 @@ module GridGenerator 
     | 
|
| 
       190 
195 
     | 
    
         
             
                      end
         
     | 
| 
       191 
196 
     | 
    
         
             
                    end.flatten.compact
         
     | 
| 
       192 
197 
     | 
    
         
             
                  end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 200 
     | 
    
         
            +
                    output = "<polygon points=\"#{ points_string }\" style=\"fill:#{ COLOURS[:fill] };stroke:#{ COLOURS[:stroke] };stroke-width:1\" />"
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                    for line in vertical_lines do
         
     | 
| 
      
 203 
     | 
    
         
            +
                      output += "<line x1=\"#{line.x1}\" y1=\"#{line.y1}\" x2=\"#{line.x2}\" y2=\"#{line.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 204 
     | 
    
         
            +
                    end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                    for line in diagonal_up_lines do
         
     | 
| 
      
 207 
     | 
    
         
            +
                      output += "<line x1=\"#{line.x1}\" y1=\"#{line.y1}\" x2=\"#{line.x2}\" y2=\"#{line.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 208 
     | 
    
         
            +
                    end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
                    for line in diagonal_down_lines do
         
     | 
| 
      
 211 
     | 
    
         
            +
                      output += "<line x1=\"#{line.x1}\" y1=\"#{line.y1}\" x2=\"#{line.x2}\" y2=\"#{line.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 212 
     | 
    
         
            +
                    end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                    element_shapes.map do |shape|
         
     | 
| 
      
 215 
     | 
    
         
            +
                      output += "<polygon points=\"#{ shape.points_string }\" style=\"fill:#{ shape.colour };stroke:#{ COLOURS[:stroke] };stroke-width:1;opacity:#{ shape.opacity }\" />"
         
     | 
| 
      
 216 
     | 
    
         
            +
                    end
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                    output
         
     | 
| 
      
 219 
     | 
    
         
            +
                  end
         
     | 
| 
       193 
220 
     | 
    
         
             
                end
         
     | 
| 
       194 
221 
     | 
    
         
             
              end
         
     | 
| 
       195 
222 
     | 
    
         
             
            end
         
     | 
| 
         @@ -5,6 +5,11 @@ require_relative 'left_element_factory' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       6 
6 
     | 
    
         
             
              module Skewb
         
     | 
| 
       7 
7 
     | 
    
         
             
                class LeftSkewbGrid < Skewb::SkewbGrid
         
     | 
| 
      
 8 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 9 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 10 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       8 
13 
     | 
    
         
             
                  def factory_class
         
     | 
| 
       9 
14 
     | 
    
         
             
                    GridGenerator::Skewb::LeftElementFactory
         
     | 
| 
       10 
15 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -49,6 +54,26 @@ module GridGenerator 
     | 
|
| 
       49 
54 
     | 
    
         
             
                      GridGenerator::Line.new(a: a, b: b) 
         
     | 
| 
       50 
55 
     | 
    
         
             
                    end
         
     | 
| 
       51 
56 
     | 
    
         
             
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 59 
     | 
    
         
            +
                    output = "<polygon points=\"#{border_points_string}\" style=\"fill:#{COLOURS[:fill]};stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    rows.each do |row|
         
     | 
| 
      
 62 
     | 
    
         
            +
                      output += "<line x1=\"#{row.x1}\" y1=\"#{row.y1}\" x2=\"#{row.x2}\" y2=\"#{row.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                    columns.each do |col|
         
     | 
| 
      
 66 
     | 
    
         
            +
                      output += "<line x1=\"#{col.x1}\" y1=\"#{col.y1}\" x2=\"#{col.x2}\" y2=\"#{col.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                    element_shapes.each do |element|
         
     | 
| 
      
 70 
     | 
    
         
            +
                      if element
         
     | 
| 
      
 71 
     | 
    
         
            +
                        output += "<polygon points=\"#{element.points_string}\" style=\"fill:#{element.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{element.opacity}\" />"
         
     | 
| 
      
 72 
     | 
    
         
            +
                      end
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                    output
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
       52 
77 
     | 
    
         
             
                end
         
     | 
| 
       53 
78 
     | 
    
         
             
              end
         
     | 
| 
       54 
79 
     | 
    
         
             
            end
         
     | 
| 
         @@ -6,6 +6,11 @@ require_relative 'right_element_factory.rb' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       7 
7 
     | 
    
         
             
              module Skewb
         
     | 
| 
       8 
8 
     | 
    
         
             
                class RightSkewbGrid < Skewb::SkewbGrid
         
     | 
| 
      
 9 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       9 
14 
     | 
    
         
             
                  def factory_class
         
     | 
| 
       10 
15 
     | 
    
         
             
                    GridGenerator::Skewb::RightElementFactory
         
     | 
| 
       11 
16 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -50,6 +55,26 @@ module GridGenerator 
     | 
|
| 
       50 
55 
     | 
    
         
             
                      GridGenerator::Line.new(a: a, b: b) 
         
     | 
| 
       51 
56 
     | 
    
         
             
                    end
         
     | 
| 
       52 
57 
     | 
    
         
             
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 60 
     | 
    
         
            +
                    output = "<polygon points=\"#{border_points_string}\" style=\"fill:#{COLOURS[:fill]};stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                    rows.each do |row|
         
     | 
| 
      
 63 
     | 
    
         
            +
                      output += "<line x1=\"#{row.x1}\" y1=\"#{row.y1}\" x2=\"#{row.x2}\" y2=\"#{row.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 64 
     | 
    
         
            +
                    end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                    columns.each do |col|
         
     | 
| 
      
 67 
     | 
    
         
            +
                      output += "<line x1=\"#{col.x1}\" y1=\"#{col.y1}\" x2=\"#{col.x2}\" y2=\"#{col.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    element_shapes.each do |element|
         
     | 
| 
      
 71 
     | 
    
         
            +
                      if element
         
     | 
| 
      
 72 
     | 
    
         
            +
                        output += "<polygon points=\"#{element.points_string}\" style=\"fill:#{element.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{element.opacity}\" />"
         
     | 
| 
      
 73 
     | 
    
         
            +
                      end
         
     | 
| 
      
 74 
     | 
    
         
            +
                    end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                    output
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
       53 
78 
     | 
    
         
             
                end
         
     | 
| 
       54 
79 
     | 
    
         
             
              end
         
     | 
| 
       55 
80 
     | 
    
         
             
            end
         
     | 
| 
         @@ -6,6 +6,11 @@ require_relative 'top_element_factory' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       7 
7 
     | 
    
         
             
              module Skewb
         
     | 
| 
       8 
8 
     | 
    
         
             
                class TopSkewbGrid < Skewb::SkewbGrid
         
     | 
| 
      
 9 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       9 
14 
     | 
    
         
             
                  def factory_class
         
     | 
| 
       10 
15 
     | 
    
         
             
                    GridGenerator::Skewb::TopElementFactory
         
     | 
| 
       11 
16 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -50,6 +55,26 @@ module GridGenerator 
     | 
|
| 
       50 
55 
     | 
    
         
             
                      GridGenerator::Line.new(a: a, b: b) 
         
     | 
| 
       51 
56 
     | 
    
         
             
                    end
         
     | 
| 
       52 
57 
     | 
    
         
             
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 60 
     | 
    
         
            +
                    output = "<polygon points=\"#{border_points_string}\" style=\"fill:#{COLOURS[:fill]};stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                    rows.each do |row|
         
     | 
| 
      
 63 
     | 
    
         
            +
                      output += "<line x1=\"#{row.x1}\" y1=\"#{row.y1}\" x2=\"#{row.x2}\" y2=\"#{row.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 64 
     | 
    
         
            +
                    end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                    columns.each do |col|
         
     | 
| 
      
 67 
     | 
    
         
            +
                      output += "<line x1=\"#{col.x1}\" y1=\"#{col.y1}\" x2=\"#{col.x2}\" y2=\"#{col.y2}\" style=\"stroke:#{COLOURS[:stroke]};stroke-width:1\" />"
         
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    element_shapes.each do |element|
         
     | 
| 
      
 71 
     | 
    
         
            +
                      if element
         
     | 
| 
      
 72 
     | 
    
         
            +
                        output += "<polygon points=\"#{element.points_string}\" style=\"fill:#{element.colour};stroke:#{COLOURS[:stroke]};stroke-width:1;opacity:#{element.opacity}\" />"
         
     | 
| 
      
 73 
     | 
    
         
            +
                      end
         
     | 
| 
      
 74 
     | 
    
         
            +
                    end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                    output
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
       53 
78 
     | 
    
         
             
                end
         
     | 
| 
       54 
79 
     | 
    
         
             
              end
         
     | 
| 
       55 
80 
     | 
    
         
             
            end
         
     | 
| 
         @@ -5,6 +5,11 @@ require_relative 'element_factory' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
       6 
6 
     | 
    
         
             
              module SquareOne
         
     | 
| 
       7 
7 
     | 
    
         
             
                class Face 
         
     | 
| 
      
 8 
     | 
    
         
            +
                  COLOURS = {
         
     | 
| 
      
 9 
     | 
    
         
            +
                    fill: "#d0d0d0",
         
     | 
| 
      
 10 
     | 
    
         
            +
                    stroke: "#404040"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       8 
13 
     | 
    
         
             
                  def initialize(x:, y: , units: , elements:, axis_direction: :forward)
         
     | 
| 
       9 
14 
     | 
    
         
             
                    @x, @y = x, y
         
     | 
| 
       10 
15 
     | 
    
         
             
                    @units = units
         
     | 
| 
         @@ -88,6 +93,20 @@ module GridGenerator 
     | 
|
| 
       88 
93 
     | 
    
         
             
                      "element_shapes" => element_shapes.map(&:as_json)
         
     | 
| 
       89 
94 
     | 
    
         
             
                    }
         
     | 
| 
       90 
95 
     | 
    
         
             
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  def to_svg
         
     | 
| 
      
 98 
     | 
    
         
            +
                    output = ""
         
     | 
| 
      
 99 
     | 
    
         
            +
                    element_shapes.each do |element|
         
     | 
| 
      
 100 
     | 
    
         
            +
                      if element.opacity == 0.4
         
     | 
| 
      
 101 
     | 
    
         
            +
                        output += "<polygon points=\"#{ element.points_string }\" style=\"fill:#{ COLOURS[:fill] };stroke:#{ COLOURS[:stroke] };stroke-width:1;opacity:1;]\" />"
         
     | 
| 
      
 102 
     | 
    
         
            +
                      end
         
     | 
| 
      
 103 
     | 
    
         
            +
                      output += "<polygon points=\"#{ element.points_string }\" style=\"fill:#{ element.colour };stroke:#{ COLOURS[:stroke] };stroke-width:1;opacity:#{ element.opacity };\" />"
         
     | 
| 
      
 104 
     | 
    
         
            +
                     end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                    output += "<line x1=\"#{ axis.x1 }\" y1=\"#{ axis.y1 }\" x2=\"#{ axis.x2 }\" y2=\"#{ axis.y2 }\" style=\"stroke:#{ COLOURS[:stroke] };stroke-width:5\" />"
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                    output
         
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
       91 
110 
     | 
    
         
             
                end
         
     | 
| 
       92 
111 
     | 
    
         
             
              end
         
     | 
| 
       93 
112 
     | 
    
         
             
            end
         
     | 
    
        data/lib/grid_generator.rb
    CHANGED
    
    | 
         @@ -13,12 +13,7 @@ require_relative 'grid_generator/skewb/top_skewb_grid' 
     | 
|
| 
       13 
13 
     | 
    
         
             
            require_relative 'grid_generator/skewb/left_skewb_grid'
         
     | 
| 
       14 
14 
     | 
    
         
             
            require_relative 'grid_generator/skewb/right_skewb_grid'
         
     | 
| 
       15 
15 
     | 
    
         
             
            require_relative 'grid_generator/square_one/face'
         
     | 
| 
       16 
     | 
    
         
            -
            require_relative 'grid_generator/arrows/vertical_arrow'
         
     | 
| 
       17 
     | 
    
         
            -
            require_relative 'grid_generator/arrows/horizontal_arrow'
         
     | 
| 
       18 
     | 
    
         
            -
            require_relative 'grid_generator/arrows/diagonal_down_arrow'
         
     | 
| 
       19 
     | 
    
         
            -
            require_relative 'grid_generator/arrows/diagonal_up_arrow'
         
     | 
| 
       20 
16 
     | 
    
         
             
            require_relative 'grid_generator/pyraminx/face'
         
     | 
| 
       21 
     | 
    
         
            -
            require_relative 'grid_generator/megaminx/face'
         
     | 
| 
       22 
17 
     | 
    
         
             
            require_relative 'grid_generator/megaminx/face_projection'
         
     | 
| 
       23 
18 
     | 
    
         | 
| 
       24 
19 
     | 
    
         
             
            module GridGenerator
         
     | 
| 
         @@ -65,30 +60,10 @@ module GridGenerator 
     | 
|
| 
       65 
60 
     | 
    
         
             
                SquareOne::Face.new(**args)
         
     | 
| 
       66 
61 
     | 
    
         
             
              end
         
     | 
| 
       67 
62 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
              def self.vertical_arrow(args)
         
     | 
| 
       69 
     | 
    
         
            -
                Arrows::VerticalArrow.new(**args)
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
              def self.horizontal_arrow(args)
         
     | 
| 
       73 
     | 
    
         
            -
                Arrows::HorizontalArrow.new(**args)
         
     | 
| 
       74 
     | 
    
         
            -
              end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
              def self.diagonal_down_arrow(args)
         
     | 
| 
       77 
     | 
    
         
            -
                Arrows::DiagonalDownArrow.new(**args)
         
     | 
| 
       78 
     | 
    
         
            -
              end
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
              def self.diagonal_up_arrow(args)
         
     | 
| 
       81 
     | 
    
         
            -
                Arrows::DiagonalUpArrow.new(**args)
         
     | 
| 
       82 
     | 
    
         
            -
              end
         
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
63 
     | 
    
         
             
              def self.pyraminx_face(args)
         
     | 
| 
       85 
64 
     | 
    
         
             
                Pyraminx::Face.new(**args)
         
     | 
| 
       86 
65 
     | 
    
         
             
              end
         
     | 
| 
       87 
66 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
              def self.megaminx_face(args)
         
     | 
| 
       89 
     | 
    
         
            -
                Megaminx::Face.new(**args)
         
     | 
| 
       90 
     | 
    
         
            -
              end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
67 
     | 
    
         
             
              def self.megaminx_face_projection(args)
         
     | 
| 
       93 
68 
     | 
    
         
             
                Megaminx::FaceProjection.new(**args)
         
     | 
| 
       94 
69 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: grid_generator
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Mark Humphreys
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-03-25 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: matrix
         
     | 
| 
         @@ -40,11 +40,6 @@ files: 
     | 
|
| 
       40 
40 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       41 
41 
     | 
    
         
             
            - grid_generator.gemspec
         
     | 
| 
       42 
42 
     | 
    
         
             
            - lib/grid_generator.rb
         
     | 
| 
       43 
     | 
    
         
            -
            - lib/grid_generator/arrows/arrow.rb
         
     | 
| 
       44 
     | 
    
         
            -
            - lib/grid_generator/arrows/diagonal_down_arrow.rb
         
     | 
| 
       45 
     | 
    
         
            -
            - lib/grid_generator/arrows/diagonal_up_arrow.rb
         
     | 
| 
       46 
     | 
    
         
            -
            - lib/grid_generator/arrows/horizontal_arrow.rb
         
     | 
| 
       47 
     | 
    
         
            -
            - lib/grid_generator/arrows/vertical_arrow.rb
         
     | 
| 
       48 
43 
     | 
    
         
             
            - lib/grid_generator/base_element.rb
         
     | 
| 
       49 
44 
     | 
    
         
             
            - lib/grid_generator/cubic/bordered_grid.rb
         
     | 
| 
       50 
45 
     | 
    
         
             
            - lib/grid_generator/cubic/facing_grid.rb
         
     | 
| 
         @@ -59,12 +54,8 @@ files: 
     | 
|
| 
       59 
54 
     | 
    
         
             
            - lib/grid_generator/face_parser.rb
         
     | 
| 
       60 
55 
     | 
    
         
             
            - lib/grid_generator/helper.rb
         
     | 
| 
       61 
56 
     | 
    
         
             
            - lib/grid_generator/line.rb
         
     | 
| 
       62 
     | 
    
         
            -
            - lib/grid_generator/megaminx/common.rb
         
     | 
| 
       63 
     | 
    
         
            -
            - lib/grid_generator/megaminx/element_factory.rb
         
     | 
| 
       64 
     | 
    
         
            -
            - lib/grid_generator/megaminx/face.rb
         
     | 
| 
       65 
57 
     | 
    
         
             
            - lib/grid_generator/megaminx/face_element_factory.rb
         
     | 
| 
       66 
58 
     | 
    
         
             
            - lib/grid_generator/megaminx/face_projection.rb
         
     | 
| 
       67 
     | 
    
         
            -
            - lib/grid_generator/megaminx/front_face.rb
         
     | 
| 
       68 
59 
     | 
    
         
             
            - lib/grid_generator/pyraminx/face.rb
         
     | 
| 
       69 
60 
     | 
    
         
             
            - lib/grid_generator/pyraminx/triangle_factory.rb
         
     | 
| 
       70 
61 
     | 
    
         
             
            - lib/grid_generator/rotator.rb
         
     | 
| 
         @@ -1,29 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       2 
     | 
    
         
            -
              module Arrows
         
     | 
| 
       3 
     | 
    
         
            -
                class Arrow
         
     | 
| 
       4 
     | 
    
         
            -
                  def initialize(x:, y:, length:, direction: :uni, colour: '#ffffff')
         
     | 
| 
       5 
     | 
    
         
            -
                    @x, @y = x, y
         
     | 
| 
       6 
     | 
    
         
            -
                    @length = length
         
     | 
| 
       7 
     | 
    
         
            -
                    @direction = direction
         
     | 
| 
       8 
     | 
    
         
            -
                    @colour = colour
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
       10 
     | 
    
         
            -
                
         
     | 
| 
       11 
     | 
    
         
            -
                  attr_reader :x, :y, :length, :direction, :colour
         
     | 
| 
       12 
     | 
    
         
            -
                
         
     | 
| 
       13 
     | 
    
         
            -
                  def points
         
     | 
| 
       14 
     | 
    
         
            -
                    []
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
                
         
     | 
| 
       17 
     | 
    
         
            -
                  def points_string
         
     | 
| 
       18 
     | 
    
         
            -
                    points.map { |p| p.join(',') }.join(' ')
         
     | 
| 
       19 
     | 
    
         
            -
                  end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                  def as_json
         
     | 
| 
       22 
     | 
    
         
            -
                    {
         
     | 
| 
       23 
     | 
    
         
            -
                      "points_string" => points_string,
         
     | 
| 
       24 
     | 
    
         
            -
                      "colour" => colour
         
     | 
| 
       25 
     | 
    
         
            -
                    }
         
     | 
| 
       26 
     | 
    
         
            -
                  end
         
     | 
| 
       27 
     | 
    
         
            -
                end
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,65 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative 'arrow'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       4 
     | 
    
         
            -
              module Arrows
         
     | 
| 
       5 
     | 
    
         
            -
                class DiagonalDownArrow < Arrow
         
     | 
| 
       6 
     | 
    
         
            -
                  ARROW_SIDE = 12
         
     | 
| 
       7 
     | 
    
         
            -
                  ARROW_OVERHANG = 4 
         
     | 
| 
       8 
     | 
    
         
            -
                
         
     | 
| 
       9 
     | 
    
         
            -
                  def arrow_start_point
         
     | 
| 
       10 
     | 
    
         
            -
                    [
         
     | 
| 
       11 
     | 
    
         
            -
                      [ x, y+ARROW_SIDE ],
         
     | 
| 
       12 
     | 
    
         
            -
                      [ x, y ],
         
     | 
| 
       13 
     | 
    
         
            -
                      [ x+ARROW_SIDE, y ]
         
     | 
| 
       14 
     | 
    
         
            -
                    ]
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
                
         
     | 
| 
       17 
     | 
    
         
            -
                  def arrow_start_flat
         
     | 
| 
       18 
     | 
    
         
            -
                    [
         
     | 
| 
       19 
     | 
    
         
            -
                      [ x, y+ARROW_SIDE-(2*ARROW_OVERHANG) ],
         
     | 
| 
       20 
     | 
    
         
            -
                      [ x+ARROW_SIDE-(2*ARROW_OVERHANG), y ]
         
     | 
| 
       21 
     | 
    
         
            -
                    ]
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
                
         
     | 
| 
       24 
     | 
    
         
            -
                  def arrow_start_side
         
     | 
| 
       25 
     | 
    
         
            -
                    [
         
     | 
| 
       26 
     | 
    
         
            -
                      [ x+ARROW_SIDE-ARROW_OVERHANG, y+ARROW_OVERHANG ],
         
     | 
| 
       27 
     | 
    
         
            -
                      [ x+(ARROW_SIDE-ARROW_OVERHANG)+length, y+length+ARROW_OVERHANG ]
         
     | 
| 
       28 
     | 
    
         
            -
                    ]
         
     | 
| 
       29 
     | 
    
         
            -
                  end
         
     | 
| 
       30 
     | 
    
         
            -
                
         
     | 
| 
       31 
     | 
    
         
            -
                  def arrow_end_point
         
     | 
| 
       32 
     | 
    
         
            -
                    [
         
     | 
| 
       33 
     | 
    
         
            -
                      [ x+ARROW_SIDE+length, y+length ],
         
     | 
| 
       34 
     | 
    
         
            -
                      [ x+ARROW_SIDE+length, y+ARROW_SIDE+length ],
         
     | 
| 
       35 
     | 
    
         
            -
                      [ x+length, y+ARROW_SIDE+length ]
         
     | 
| 
       36 
     | 
    
         
            -
                    ]
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
                
         
     | 
| 
       39 
     | 
    
         
            -
                  def arrow_end_flat
         
     | 
| 
       40 
     | 
    
         
            -
                    [
         
     | 
| 
       41 
     | 
    
         
            -
                      [ x+ARROW_SIDE+length, y+length+(2*ARROW_OVERHANG) ],
         
     | 
| 
       42 
     | 
    
         
            -
                      [ x+length+(2*ARROW_OVERHANG), y+ARROW_SIDE+length ]
         
     | 
| 
       43 
     | 
    
         
            -
                    ]
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
                
         
     | 
| 
       46 
     | 
    
         
            -
                  def arrow_end_side
         
     | 
| 
       47 
     | 
    
         
            -
                    [
         
     | 
| 
       48 
     | 
    
         
            -
                      [ x+length+ARROW_OVERHANG, y+ARROW_SIDE+length-ARROW_OVERHANG ],
         
     | 
| 
       49 
     | 
    
         
            -
                      [ x+ARROW_OVERHANG, y+ARROW_SIDE-ARROW_OVERHANG ]
         
     | 
| 
       50 
     | 
    
         
            -
                    ]
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
                
         
     | 
| 
       53 
     | 
    
         
            -
                  def points
         
     | 
| 
       54 
     | 
    
         
            -
                    case direction
         
     | 
| 
       55 
     | 
    
         
            -
                    when :forward
         
     | 
| 
       56 
     | 
    
         
            -
                      arrow_start_flat + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       57 
     | 
    
         
            -
                    when :backward
         
     | 
| 
       58 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_flat + arrow_end_side
         
     | 
| 
       59 
     | 
    
         
            -
                    else
         
     | 
| 
       60 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       61 
     | 
    
         
            -
                    end
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
                end
         
     | 
| 
       64 
     | 
    
         
            -
              end
         
     | 
| 
       65 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,66 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative 'arrow'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       4 
     | 
    
         
            -
              module Arrows
         
     | 
| 
       5 
     | 
    
         
            -
                class DiagonalUpArrow < Arrow
         
     | 
| 
       6 
     | 
    
         
            -
                  ARROW_SIDE = 12
         
     | 
| 
       7 
     | 
    
         
            -
                  ARROW_OVERHANG = 4 
         
     | 
| 
       8 
     | 
    
         
            -
                
         
     | 
| 
       9 
     | 
    
         
            -
                  def arrow_start_point
         
     | 
| 
       10 
     | 
    
         
            -
                    [
         
     | 
| 
       11 
     | 
    
         
            -
                      [ x+ARROW_SIDE, y+length+ARROW_SIDE ],
         
     | 
| 
       12 
     | 
    
         
            -
                      [ x, y+length+ARROW_SIDE ],
         
     | 
| 
       13 
     | 
    
         
            -
                      [ x, y+length ]
         
     | 
| 
       14 
     | 
    
         
            -
                    ]
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
                
         
     | 
| 
       17 
     | 
    
         
            -
                  def arrow_start_flat
         
     | 
| 
       18 
     | 
    
         
            -
                    [
         
     | 
| 
       19 
     | 
    
         
            -
                      [ x+ARROW_SIDE-(2*ARROW_OVERHANG), y+length+ARROW_SIDE ],
         
     | 
| 
       20 
     | 
    
         
            -
                      [ x, y+length+(2*ARROW_OVERHANG) ]
         
     | 
| 
       21 
     | 
    
         
            -
                    ]
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
                
         
     | 
| 
       24 
     | 
    
         
            -
                  def arrow_start_side
         
     | 
| 
       25 
     | 
    
         
            -
                    [
         
     | 
| 
       26 
     | 
    
         
            -
                      [ x+ARROW_OVERHANG, y+length+ARROW_OVERHANG ],
         
     | 
| 
       27 
     | 
    
         
            -
                      [ x+length+ARROW_OVERHANG, y+ARROW_OVERHANG ]
         
     | 
| 
       28 
     | 
    
         
            -
                    ]
         
     | 
| 
       29 
     | 
    
         
            -
                  end
         
     | 
| 
       30 
     | 
    
         
            -
                
         
     | 
| 
       31 
     | 
    
         
            -
                  def arrow_end_point
         
     | 
| 
       32 
     | 
    
         
            -
                    [
         
     | 
| 
       33 
     | 
    
         
            -
                      [ x+length, y ],
         
     | 
| 
       34 
     | 
    
         
            -
                      [ x+length+ARROW_SIDE, y ],
         
     | 
| 
       35 
     | 
    
         
            -
                      [ x+length+ARROW_SIDE, y+ARROW_SIDE ]
         
     | 
| 
       36 
     | 
    
         
            -
                    ]
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
                
         
     | 
| 
       39 
     | 
    
         
            -
                  def arrow_end_flat
         
     | 
| 
       40 
     | 
    
         
            -
                    [
         
     | 
| 
       41 
     | 
    
         
            -
                      [ x+length+(2*ARROW_OVERHANG), y ],
         
     | 
| 
       42 
     | 
    
         
            -
                      [ x+length+ARROW_SIDE, y+ARROW_SIDE-(2*ARROW_OVERHANG) ]
         
     | 
| 
       43 
     | 
    
         
            -
                    ]
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
                
         
     | 
| 
       46 
     | 
    
         
            -
                  def arrow_end_side
         
     | 
| 
       47 
     | 
    
         
            -
                    [
         
     | 
| 
       48 
     | 
    
         
            -
                      [ x+length+ARROW_SIDE-ARROW_OVERHANG, y+ARROW_SIDE-ARROW_OVERHANG ],
         
     | 
| 
       49 
     | 
    
         
            -
                      [ x+ARROW_SIDE-ARROW_OVERHANG, y+length+ARROW_SIDE-ARROW_OVERHANG ]
         
     | 
| 
       50 
     | 
    
         
            -
                    ]
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
                
         
     | 
| 
       53 
     | 
    
         
            -
                  def points
         
     | 
| 
       54 
     | 
    
         
            -
                    case direction
         
     | 
| 
       55 
     | 
    
         
            -
                    when :forward
         
     | 
| 
       56 
     | 
    
         
            -
                      arrow_start_flat + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       57 
     | 
    
         
            -
                    when :backward
         
     | 
| 
       58 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_flat + arrow_end_side
         
     | 
| 
       59 
     | 
    
         
            -
                    else
         
     | 
| 
       60 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       61 
     | 
    
         
            -
                    end
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
                
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
              end
         
     | 
| 
       66 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,66 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative 'arrow'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       4 
     | 
    
         
            -
              module Arrows
         
     | 
| 
       5 
     | 
    
         
            -
                class HorizontalArrow < Arrow
         
     | 
| 
       6 
     | 
    
         
            -
                  ARROW_WIDTH = 16
         
     | 
| 
       7 
     | 
    
         
            -
                  ARROW_LENGTH = 8
         
     | 
| 
       8 
     | 
    
         
            -
                  LINE_WIDTH = 6
         
     | 
| 
       9 
     | 
    
         
            -
                
         
     | 
| 
       10 
     | 
    
         
            -
                  def arrow_start_point
         
     | 
| 
       11 
     | 
    
         
            -
                    [
         
     | 
| 
       12 
     | 
    
         
            -
                      [ x+ARROW_LENGTH, y+ARROW_WIDTH ],
         
     | 
| 
       13 
     | 
    
         
            -
                      [ x, y+(ARROW_WIDTH/2) ],
         
     | 
| 
       14 
     | 
    
         
            -
                      [ x+ARROW_LENGTH, y ]
         
     | 
| 
       15 
     | 
    
         
            -
                    ]
         
     | 
| 
       16 
     | 
    
         
            -
                  end
         
     | 
| 
       17 
     | 
    
         
            -
                
         
     | 
| 
       18 
     | 
    
         
            -
                  def arrow_start_flat
         
     | 
| 
       19 
     | 
    
         
            -
                    [
         
     | 
| 
       20 
     | 
    
         
            -
                      [ x, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ],
         
     | 
| 
       21 
     | 
    
         
            -
                      [ x, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ]
         
     | 
| 
       22 
     | 
    
         
            -
                    ]
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
                
         
     | 
| 
       25 
     | 
    
         
            -
                  def arrow_start_side
         
     | 
| 
       26 
     | 
    
         
            -
                    [
         
     | 
| 
       27 
     | 
    
         
            -
                      [ x+ARROW_LENGTH, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ],
         
     | 
| 
       28 
     | 
    
         
            -
                      [ x+ARROW_LENGTH+length, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ]
         
     | 
| 
       29 
     | 
    
         
            -
                    ]
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                
         
     | 
| 
       32 
     | 
    
         
            -
                  def arrow_end_point
         
     | 
| 
       33 
     | 
    
         
            -
                    [
         
     | 
| 
       34 
     | 
    
         
            -
                      [ x+ARROW_LENGTH+length, y ],
         
     | 
| 
       35 
     | 
    
         
            -
                      [ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2) ],
         
     | 
| 
       36 
     | 
    
         
            -
                      [ x+ARROW_LENGTH+length, y+ARROW_WIDTH ]
         
     | 
| 
       37 
     | 
    
         
            -
                    ]
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
     | 
    
         
            -
                
         
     | 
| 
       40 
     | 
    
         
            -
                  def arrow_end_flat
         
     | 
| 
       41 
     | 
    
         
            -
                    [
         
     | 
| 
       42 
     | 
    
         
            -
                      [ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ],
         
     | 
| 
       43 
     | 
    
         
            -
                      [ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ]
         
     | 
| 
       44 
     | 
    
         
            -
                    ]
         
     | 
| 
       45 
     | 
    
         
            -
                  end
         
     | 
| 
       46 
     | 
    
         
            -
                
         
     | 
| 
       47 
     | 
    
         
            -
                  def arrow_end_side
         
     | 
| 
       48 
     | 
    
         
            -
                    [
         
     | 
| 
       49 
     | 
    
         
            -
                      [ x+ARROW_LENGTH+length, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ],
         
     | 
| 
       50 
     | 
    
         
            -
                      [ x+ARROW_LENGTH, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ]
         
     | 
| 
       51 
     | 
    
         
            -
                    ]
         
     | 
| 
       52 
     | 
    
         
            -
                  end 
         
     | 
| 
       53 
     | 
    
         
            -
                
         
     | 
| 
       54 
     | 
    
         
            -
                  def points
         
     | 
| 
       55 
     | 
    
         
            -
                    case direction
         
     | 
| 
       56 
     | 
    
         
            -
                    when :forward
         
     | 
| 
       57 
     | 
    
         
            -
                      arrow_start_flat + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       58 
     | 
    
         
            -
                    when :backward
         
     | 
| 
       59 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_flat + arrow_end_side
         
     | 
| 
       60 
     | 
    
         
            -
                    else
         
     | 
| 
       61 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       62 
     | 
    
         
            -
                    end
         
     | 
| 
       63 
     | 
    
         
            -
                  end
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
              end
         
     | 
| 
       66 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,66 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative 'arrow'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       4 
     | 
    
         
            -
              module Arrows
         
     | 
| 
       5 
     | 
    
         
            -
                class VerticalArrow < Arrow
         
     | 
| 
       6 
     | 
    
         
            -
                  ARROW_WIDTH = 16
         
     | 
| 
       7 
     | 
    
         
            -
                  ARROW_LENGTH = 8
         
     | 
| 
       8 
     | 
    
         
            -
                  LINE_WIDTH = 6
         
     | 
| 
       9 
     | 
    
         
            -
                
         
     | 
| 
       10 
     | 
    
         
            -
                  def arrow_start_point
         
     | 
| 
       11 
     | 
    
         
            -
                    [
         
     | 
| 
       12 
     | 
    
         
            -
                      [ x, y+ARROW_LENGTH ],
         
     | 
| 
       13 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2), y ],
         
     | 
| 
       14 
     | 
    
         
            -
                      [ x+ARROW_WIDTH, y+ARROW_LENGTH ]
         
     | 
| 
       15 
     | 
    
         
            -
                    ]
         
     | 
| 
       16 
     | 
    
         
            -
                  end
         
     | 
| 
       17 
     | 
    
         
            -
                
         
     | 
| 
       18 
     | 
    
         
            -
                  def arrow_start_flat
         
     | 
| 
       19 
     | 
    
         
            -
                    [
         
     | 
| 
       20 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y ],
         
     | 
| 
       21 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y ]
         
     | 
| 
       22 
     | 
    
         
            -
                    ]
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
                
         
     | 
| 
       25 
     | 
    
         
            -
                  def arrow_start_side
         
     | 
| 
       26 
     | 
    
         
            -
                    [
         
     | 
| 
       27 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y+ARROW_LENGTH ],
         
     | 
| 
       28 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y+ARROW_LENGTH+length ]
         
     | 
| 
       29 
     | 
    
         
            -
                    ]
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                
         
     | 
| 
       32 
     | 
    
         
            -
                  def arrow_end_point
         
     | 
| 
       33 
     | 
    
         
            -
                    [
         
     | 
| 
       34 
     | 
    
         
            -
                      [ x+ARROW_WIDTH, y+ARROW_LENGTH+length ],
         
     | 
| 
       35 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2), y+(ARROW_LENGTH*2)+length ],
         
     | 
| 
       36 
     | 
    
         
            -
                      [ x, y+ARROW_LENGTH+length ]
         
     | 
| 
       37 
     | 
    
         
            -
                    ]
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
     | 
    
         
            -
                
         
     | 
| 
       40 
     | 
    
         
            -
                  def arrow_end_flat
         
     | 
| 
       41 
     | 
    
         
            -
                    [
         
     | 
| 
       42 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y+(2*ARROW_LENGTH)+length ],
         
     | 
| 
       43 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y+(2*ARROW_LENGTH)+length ]
         
     | 
| 
       44 
     | 
    
         
            -
                    ]
         
     | 
| 
       45 
     | 
    
         
            -
                  end
         
     | 
| 
       46 
     | 
    
         
            -
                
         
     | 
| 
       47 
     | 
    
         
            -
                  def arrow_end_side
         
     | 
| 
       48 
     | 
    
         
            -
                    [
         
     | 
| 
       49 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y+ARROW_LENGTH+length ],
         
     | 
| 
       50 
     | 
    
         
            -
                      [ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y+ARROW_LENGTH ]
         
     | 
| 
       51 
     | 
    
         
            -
                    ]
         
     | 
| 
       52 
     | 
    
         
            -
                  end
         
     | 
| 
       53 
     | 
    
         
            -
                
         
     | 
| 
       54 
     | 
    
         
            -
                  def points
         
     | 
| 
       55 
     | 
    
         
            -
                    case direction
         
     | 
| 
       56 
     | 
    
         
            -
                    when :forward
         
     | 
| 
       57 
     | 
    
         
            -
                      arrow_start_flat + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       58 
     | 
    
         
            -
                    when :backward
         
     | 
| 
       59 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_flat + arrow_end_side
         
     | 
| 
       60 
     | 
    
         
            -
                    else
         
     | 
| 
       61 
     | 
    
         
            -
                      arrow_start_point + arrow_start_side + arrow_end_point + arrow_end_side
         
     | 
| 
       62 
     | 
    
         
            -
                    end
         
     | 
| 
       63 
     | 
    
         
            -
                  end
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
              end
         
     | 
| 
       66 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,95 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'matrix'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       4 
     | 
    
         
            -
              module Megaminx
         
     | 
| 
       5 
     | 
    
         
            -
                module Common
         
     | 
| 
       6 
     | 
    
         
            -
                  ROTATION_STEP = 2 * Math::PI / 5
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                  ROTATION_MATRIX = Proc.new do |theta|
         
     | 
| 
       9 
     | 
    
         
            -
                    Matrix[
         
     | 
| 
       10 
     | 
    
         
            -
                      [Math.cos(theta), -1*Math.sin(theta)], 
         
     | 
| 
       11 
     | 
    
         
            -
                      [Math.sin(theta), Math.cos(theta)]
         
     | 
| 
       12 
     | 
    
         
            -
                    ]
         
     | 
| 
       13 
     | 
    
         
            -
                  end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                  ROTATION_MATRICES = Array.new(5) do |i|
         
     | 
| 
       16 
     | 
    
         
            -
                    ROTATION_MATRIX.call(ROTATION_STEP * i)
         
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  def rotation_offset_matrix 
         
     | 
| 
       20 
     | 
    
         
            -
                    @rotation_offset_matrix ||= ROTATION_MATRIX.call(rotation_offset)
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  def rotation_point
         
     | 
| 
       24 
     | 
    
         
            -
                    @rotation_point ||= Matrix.column_vector([x+2*units, y+2*units])
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  def rotate(matrix, point)
         
     | 
| 
       28 
     | 
    
         
            -
                    (matrix * (point - rotation_point)) + rotation_point
         
     | 
| 
       29 
     | 
    
         
            -
                  end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  # line
         
     | 
| 
       32 
     | 
    
         
            -
              
         
     | 
| 
       33 
     | 
    
         
            -
                  def intersection(a,b,c,d)
         
     | 
| 
       34 
     | 
    
         
            -
                    x1 = a[0,0]
         
     | 
| 
       35 
     | 
    
         
            -
                    y1 = a[1,0] 
         
     | 
| 
       36 
     | 
    
         
            -
                    x2 = b[0,0]
         
     | 
| 
       37 
     | 
    
         
            -
                    y2 = b[1,0]
         
     | 
| 
       38 
     | 
    
         
            -
                    x3 = c[0,0]
         
     | 
| 
       39 
     | 
    
         
            -
                    y3 = c[1,0]
         
     | 
| 
       40 
     | 
    
         
            -
                    x4 = d[0,0]
         
     | 
| 
       41 
     | 
    
         
            -
                    y4 = d[1,0] 
         
     | 
| 
       42 
     | 
    
         
            -
              
         
     | 
| 
       43 
     | 
    
         
            -
                    px_numerator = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)
         
     | 
| 
       44 
     | 
    
         
            -
                    px_denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4) 
         
     | 
| 
       45 
     | 
    
         
            -
              
         
     | 
| 
       46 
     | 
    
         
            -
                    py_numerator = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)
         
     | 
| 
       47 
     | 
    
         
            -
                    py_denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
         
     | 
| 
       48 
     | 
    
         
            -
              
         
     | 
| 
       49 
     | 
    
         
            -
                    px = px_numerator / px_denominator
         
     | 
| 
       50 
     | 
    
         
            -
                    py = py_numerator / py_denominator
         
     | 
| 
       51 
     | 
    
         
            -
              
         
     | 
| 
       52 
     | 
    
         
            -
                    Matrix.column_vector([px, py])
         
     | 
| 
       53 
     | 
    
         
            -
                  end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                  # points
         
     | 
| 
       56 
     | 
    
         
            -
                  
         
     | 
| 
       57 
     | 
    
         
            -
                  def top_outer_corner
         
     | 
| 
       58 
     | 
    
         
            -
                    @top_outer_corner ||= rotate(rotation_offset_matrix, Matrix.column_vector([x+2*units,y]))
         
     | 
| 
       59 
     | 
    
         
            -
                  end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                  def top_outer_edge
         
     | 
| 
       62 
     | 
    
         
            -
                    point_a, point_b = outer_corners.first(2)
         
     | 
| 
       63 
     | 
    
         
            -
                    @top_outer_edge = (point_a + point_b) / 2 
         
     | 
| 
       64 
     | 
    
         
            -
                  end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                  def top_inner_corner
         
     | 
| 
       67 
     | 
    
         
            -
                    intersection(outer_edges[4], outer_edges[1], outer_edges[3], outer_edges[0])
         
     | 
| 
       68 
     | 
    
         
            -
                  end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                  def outer_corners
         
     | 
| 
       71 
     | 
    
         
            -
                    @outer_corners ||= ROTATION_MATRICES.map do |matrix|
         
     | 
| 
       72 
     | 
    
         
            -
                      rotate(matrix, top_outer_corner)
         
     | 
| 
       73 
     | 
    
         
            -
                    end
         
     | 
| 
       74 
     | 
    
         
            -
                  end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                  def outer_edges
         
     | 
| 
       77 
     | 
    
         
            -
                    @outer_edges ||= ROTATION_MATRICES.map do |matrix|
         
     | 
| 
       78 
     | 
    
         
            -
                      rotate(matrix, top_outer_edge)
         
     | 
| 
       79 
     | 
    
         
            -
                    end
         
     | 
| 
       80 
     | 
    
         
            -
                  end
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                  def inner_corners
         
     | 
| 
       83 
     | 
    
         
            -
                    @inner_corners ||= ROTATION_MATRICES.map do |matrix|
         
     | 
| 
       84 
     | 
    
         
            -
                      rotate(matrix, top_inner_corner)
         
     | 
| 
       85 
     | 
    
         
            -
                    end
         
     | 
| 
       86 
     | 
    
         
            -
                  end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                  def outer_edges_ordered_by_evens_then_odds
         
     | 
| 
       89 
     | 
    
         
            -
                    evens = outer_edges.select.with_index { |_,i| i % 2 == 0 } 
         
     | 
| 
       90 
     | 
    
         
            -
                    odds = outer_edges.select.with_index { |_,i| i % 2 == 1 } 
         
     | 
| 
       91 
     | 
    
         
            -
                    evens + odds
         
     | 
| 
       92 
     | 
    
         
            -
                  end
         
     | 
| 
       93 
     | 
    
         
            -
                end
         
     | 
| 
       94 
     | 
    
         
            -
              end
         
     | 
| 
       95 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,52 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../base_element'
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative 'common'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       5 
     | 
    
         
            -
              module Megaminx
         
     | 
| 
       6 
     | 
    
         
            -
                class ElementFactory
         
     | 
| 
       7 
     | 
    
         
            -
                  include GridGenerator::Megaminx::Common
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                  CENTER_INDEX = 0
         
     | 
| 
       10 
     | 
    
         
            -
                  EDGE_INDEX = 1
         
     | 
| 
       11 
     | 
    
         
            -
                  CORNER_INDEX = 2
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                  def initialize(x: , y:, row_index:, element_index:, units:, colour:, opacity:, rotation_offset: 0) 
         
     | 
| 
       14 
     | 
    
         
            -
                    @x, @y = x, y
         
     | 
| 
       15 
     | 
    
         
            -
                    @row_index = row_index
         
     | 
| 
       16 
     | 
    
         
            -
                    @element_index = element_index
         
     | 
| 
       17 
     | 
    
         
            -
                    @units = units
         
     | 
| 
       18 
     | 
    
         
            -
                    @colour = colour
         
     | 
| 
       19 
     | 
    
         
            -
                    @opacity = opacity
         
     | 
| 
       20 
     | 
    
         
            -
                    @rotation_offset = rotation_offset
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  attr_reader :x, :y, :row_index, :element_index, :units, :colour, :opacity, :rotation_offset
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  def points
         
     | 
| 
       26 
     | 
    
         
            -
                    case row_index
         
     | 
| 
       27 
     | 
    
         
            -
                    when CENTER_INDEX
         
     | 
| 
       28 
     | 
    
         
            -
                      inner_corners  
         
     | 
| 
       29 
     | 
    
         
            -
                    when EDGE_INDEX
         
     | 
| 
       30 
     | 
    
         
            -
                      [
         
     | 
| 
       31 
     | 
    
         
            -
                        outer_edges[element_index], 
         
     | 
| 
       32 
     | 
    
         
            -
                        inner_corners[(element_index+1) % 5], 
         
     | 
| 
       33 
     | 
    
         
            -
                        inner_corners[element_index], 
         
     | 
| 
       34 
     | 
    
         
            -
                      ]
         
     | 
| 
       35 
     | 
    
         
            -
                    when CORNER_INDEX
         
     | 
| 
       36 
     | 
    
         
            -
                      [
         
     | 
| 
       37 
     | 
    
         
            -
                        outer_corners[element_index], 
         
     | 
| 
       38 
     | 
    
         
            -
                        outer_edges[element_index], 
         
     | 
| 
       39 
     | 
    
         
            -
                        inner_corners[element_index], 
         
     | 
| 
       40 
     | 
    
         
            -
                        outer_edges[(element_index-1) % 5], 
         
     | 
| 
       41 
     | 
    
         
            -
                      ]
         
     | 
| 
       42 
     | 
    
         
            -
                    else
         
     | 
| 
       43 
     | 
    
         
            -
                      raise ArgumentError, "unknown row #{row_index}"
         
     | 
| 
       44 
     | 
    
         
            -
                    end
         
     | 
| 
       45 
     | 
    
         
            -
                  end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                  def build
         
     | 
| 
       48 
     | 
    
         
            -
                    GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity)
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
              end
         
     | 
| 
       52 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,79 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../face_parser'
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative 'common'
         
     | 
| 
       3 
     | 
    
         
            -
            require_relative 'element_factory'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module GridGenerator
         
     | 
| 
       6 
     | 
    
         
            -
              module Megaminx
         
     | 
| 
       7 
     | 
    
         
            -
                class Face
         
     | 
| 
       8 
     | 
    
         
            -
                  include GridGenerator::Megaminx::Common
         
     | 
| 
       9 
     | 
    
         
            -
              
         
     | 
| 
       10 
     | 
    
         
            -
                  def initialize(x:, y: , units: , elements: , rotation_offset: 0, label: nil)
         
     | 
| 
       11 
     | 
    
         
            -
                    @x, @y = x, y
         
     | 
| 
       12 
     | 
    
         
            -
                    @units = units
         
     | 
| 
       13 
     | 
    
         
            -
                    @elements = FaceParser.new(elements).parse
         
     | 
| 
       14 
     | 
    
         
            -
                    @rotation_offset = rotation_offset
         
     | 
| 
       15 
     | 
    
         
            -
                    @label = label
         
     | 
| 
       16 
     | 
    
         
            -
                  end
         
     | 
| 
       17 
     | 
    
         
            -
              
         
     | 
| 
       18 
     | 
    
         
            -
                  attr_reader :x, :y, :units, :elements, :rotation_offset, :label
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                  # outline
         
     | 
| 
       21 
     | 
    
         
            -
                  
         
     | 
| 
       22 
     | 
    
         
            -
                  def outline_string
         
     | 
| 
       23 
     | 
    
         
            -
                    outer_corners.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
         
     | 
| 
       24 
     | 
    
         
            -
                  end
         
     | 
| 
       25 
     | 
    
         
            -
              
         
     | 
| 
       26 
     | 
    
         
            -
                  def inner_string
         
     | 
| 
       27 
     | 
    
         
            -
                    inner_corners.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
         
     | 
| 
       28 
     | 
    
         
            -
                  end
         
     | 
| 
       29 
     | 
    
         
            -
              
         
     | 
| 
       30 
     | 
    
         
            -
                  def inline_string
         
     | 
| 
       31 
     | 
    
         
            -
                    outer_edges_ordered_by_evens_then_odds.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
     | 
    
         
            -
              
         
     | 
| 
       34 
     | 
    
         
            -
                  # elements 
         
     | 
| 
       35 
     | 
    
         
            -
                  
         
     | 
| 
       36 
     | 
    
         
            -
                  def element_shapes
         
     | 
| 
       37 
     | 
    
         
            -
                    elements.each_with_index.map do |row, row_index|
         
     | 
| 
       38 
     | 
    
         
            -
                      row.each_with_index.map do |element, element_index|
         
     | 
| 
       39 
     | 
    
         
            -
                        GridGenerator::Megaminx::ElementFactory.new(
         
     | 
| 
       40 
     | 
    
         
            -
                          x: x,
         
     | 
| 
       41 
     | 
    
         
            -
                          y: y,
         
     | 
| 
       42 
     | 
    
         
            -
                          row_index: row_index,
         
     | 
| 
       43 
     | 
    
         
            -
                          element_index: element_index,
         
     | 
| 
       44 
     | 
    
         
            -
                          units: units,
         
     | 
| 
       45 
     | 
    
         
            -
                          colour: element[:colour],
         
     | 
| 
       46 
     | 
    
         
            -
                          opacity: element[:opacity],
         
     | 
| 
       47 
     | 
    
         
            -
                          rotation_offset: rotation_offset
         
     | 
| 
       48 
     | 
    
         
            -
                        ).build if element
         
     | 
| 
       49 
     | 
    
         
            -
                      end
         
     | 
| 
       50 
     | 
    
         
            -
                    end.flatten.compact
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                  # label methods
         
     | 
| 
       54 
     | 
    
         
            -
              
         
     | 
| 
       55 
     | 
    
         
            -
                  def label_position
         
     | 
| 
       56 
     | 
    
         
            -
                    x = rotation_point[0,0] - units*0.3
         
     | 
| 
       57 
     | 
    
         
            -
                    y = rotation_point[1,0] + units*0.4
         
     | 
| 
       58 
     | 
    
         
            -
                    {
         
     | 
| 
       59 
     | 
    
         
            -
                      x: x.round, 
         
     | 
| 
       60 
     | 
    
         
            -
                      y: y.round 
         
     | 
| 
       61 
     | 
    
         
            -
                    }
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
              
         
     | 
| 
       64 
     | 
    
         
            -
                  def label_size
         
     | 
| 
       65 
     | 
    
         
            -
                    units
         
     | 
| 
       66 
     | 
    
         
            -
                  end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                  def as_json
         
     | 
| 
       69 
     | 
    
         
            -
                    {
         
     | 
| 
       70 
     | 
    
         
            -
                      "outline_string" => outline_string,
         
     | 
| 
       71 
     | 
    
         
            -
                      "inline_string" => inline_string,
         
     | 
| 
       72 
     | 
    
         
            -
                      "element_shapes" => element_shapes.as_json,
         
     | 
| 
       73 
     | 
    
         
            -
                      "label_position" => label_position,
         
     | 
| 
       74 
     | 
    
         
            -
                      "label_size" => label_size
         
     | 
| 
       75 
     | 
    
         
            -
                    }
         
     | 
| 
       76 
     | 
    
         
            -
                  end
         
     | 
| 
       77 
     | 
    
         
            -
                end
         
     | 
| 
       78 
     | 
    
         
            -
              end
         
     | 
| 
       79 
     | 
    
         
            -
            end
         
     |