grid_generator 0.1.0 → 0.1.2

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +20 -10
  4. data/lib/grid_generator/arrows/diagonal_down_arrow.rb +1 -1
  5. data/lib/grid_generator/arrows/diagonal_up_arrow.rb +1 -1
  6. data/lib/grid_generator/arrows/horizontal_arrow.rb +1 -1
  7. data/lib/grid_generator/arrows/vertical_arrow.rb +1 -1
  8. data/lib/grid_generator/base_line.rb +26 -0
  9. data/lib/grid_generator/cubic/bordered_grid.rb +15 -14
  10. data/lib/grid_generator/cubic/facing_grid.rb +15 -14
  11. data/lib/grid_generator/cubic/facing_square_factory.rb +1 -1
  12. data/lib/grid_generator/cubic/front_grid.rb +1 -1
  13. data/lib/grid_generator/cubic/grid.rb +14 -13
  14. data/lib/grid_generator/cubic/iso_view.rb +4 -0
  15. data/lib/grid_generator/cubic/right_grid.rb +1 -1
  16. data/lib/grid_generator/cubic/square_factory.rb +1 -1
  17. data/lib/grid_generator/cubic/top_grid.rb +1 -1
  18. data/lib/grid_generator/megaminx/common.rb +1 -0
  19. data/lib/grid_generator/megaminx/element_factory.rb +2 -2
  20. data/lib/grid_generator/megaminx/face.rb +3 -3
  21. data/lib/grid_generator/pyraminx/grid.rb +20 -19
  22. data/lib/grid_generator/pyraminx/triangle_factory.rb +1 -1
  23. data/lib/grid_generator/skewb/left_element_factory.rb +2 -0
  24. data/lib/grid_generator/skewb/left_skewb_grid.rb +7 -6
  25. data/lib/grid_generator/skewb/right_element_factory.rb +2 -0
  26. data/lib/grid_generator/skewb/right_skewb_grid.rb +7 -6
  27. data/lib/grid_generator/skewb/skewb_grid.rb +1 -1
  28. data/lib/grid_generator/skewb/top_element_factory.rb +2 -0
  29. data/lib/grid_generator/skewb/top_skewb_grid.rb +7 -6
  30. data/lib/grid_generator/square_one/element_factory.rb +1 -1
  31. data/lib/grid_generator/square_one/face.rb +7 -6
  32. data/lib/grid_generator/version.rb +1 -1
  33. data/lib/grid_generator.rb +17 -17
  34. metadata +3 -3
  35. data/lib/grid_generator/square_one/element.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 354f6d7c26815275c2e0fe9362d949ba46fed6952c563c3fbaa2cd1706df0119
4
- data.tar.gz: 0ba1e09b47296264b8d783179ce39cb719aaeb1463131bd4ae7c93f112dde70e
3
+ metadata.gz: e6f97c8ba195b68150195c0f9c90ca93dccc6c56bb5b466336b2065b7473c9ac
4
+ data.tar.gz: df39197455ecf27cd3d0076ea823c896bc3b0921e0df7465a0ea9cabe35e3d06
5
5
  SHA512:
6
- metadata.gz: 6824d24e5a61e8b5b7ed125ecadfc9695cd27b0f60cfcad42b61cd4d364c270e16c346c24d320da6332d69ba8f2f58064633f0c33594992d4575603ba0b540a1
7
- data.tar.gz: 977769a202c6d33ad3f8c89b0edaac847c2fb6f7cc80a9eac9f076836a2c614d29a9c1ad31ff21f1cb55049445238c988457ac39f1cd185dfb8a0b1ca5505f6c
6
+ metadata.gz: fea3c95d57111ef8b85ada074e70b564bbddf8242c7983b596df9dd640f3d43670fe45ceeca6c20fef5e57cfdc76be8805f9c4acd4402f2a89eae1ea3107e23b
7
+ data.tar.gz: 7fc49ccb79bea5b62b40a42c36a1698cbd7b0437bf852fc90ae48d0b0c1377e2152d28edc099a93bf80b4811931baab49226bf6635905f43f8adb5b5d393c0c9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grid_generator (0.1.0)
4
+ grid_generator (0.1.2)
5
5
  matrix (~> 0.4.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,24 +1,34 @@
1
1
  # GridGenerator
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/grid_generator`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Library for generating grids based on twisty puzzles. The output can be used in svg `polygon` and `line` elements.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9
+ $ bundle add grid_generator
14
10
 
15
11
  If bundler is not being used to manage dependencies, install the gem by executing:
16
12
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install grid_generator
18
14
 
19
15
  ## Usage
20
16
 
21
- TODO: Write usage instructions here
17
+ Generate an iso grid at co-ordinates 20, 20, with each unit being 20.
18
+
19
+ Squares arguments are csv-like with commas separating elements and newlines separating rows.
20
+
21
+ Each element can be a colour, represented by a letter, or blank, represented by a dash.
22
+
23
+ ```
24
+ grid = GridGenerator.iso_view(x: 20, y: 20, units: 20, top_squares: "-,-,-\\n-,-,R\\n-,-,W", front_squares: "-,-,R\\n-,b,-\\n-,b,-", right_squares: "B,B,-\\n-,r,-\\n-,r,-")
25
+ ```
26
+
27
+ Serialized the data for use in svg polygon and line elements:
28
+
29
+ ```
30
+ grid.as_json
31
+ ```
22
32
 
23
33
  ## Development
24
34
 
@@ -28,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
38
 
29
39
  ## Contributing
30
40
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/grid_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/grid_generator/blob/main/CODE_OF_CONDUCT.md).
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/grid_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mrlhumphreys/grid_generator/blob/main/CODE_OF_CONDUCT.md).
32
42
 
33
43
  ## License
34
44
 
@@ -36,4 +46,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
46
 
37
47
  ## Code of Conduct
38
48
 
39
- Everyone interacting in the GridGenerator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/grid_generator/blob/main/CODE_OF_CONDUCT.md).
49
+ Everyone interacting in the GridGenerator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mrlhumphreys/grid_generator/blob/main/CODE_OF_CONDUCT.md).
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/arrows/arrow.rb'
1
+ require_relative 'arrow'
2
2
 
3
3
  module GridGenerator
4
4
  module Arrows
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/arrows/arrow.rb'
1
+ require_relative 'arrow'
2
2
 
3
3
  module GridGenerator
4
4
  module Arrows
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/arrows/arrow.rb'
1
+ require_relative 'arrow'
2
2
 
3
3
  module GridGenerator
4
4
  module Arrows
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/arrows/arrow.rb'
1
+ require_relative 'arrow'
2
2
 
3
3
  module GridGenerator
4
4
  module Arrows
@@ -0,0 +1,26 @@
1
+ module GridGenerator
2
+ class BaseLine
3
+ def initialize(x1:, y1:, x2:, y2:)
4
+ @x1, @y1 = x1, y1
5
+ @x2, @y2 = x2, y2
6
+ end
7
+
8
+ attr_reader :x1, :y1, :x2, :y2
9
+
10
+ def ==(other)
11
+ self.x1 == other.x1 &&
12
+ self.y1 == other.y1 &&
13
+ self.x2 == other.x2 &&
14
+ self.y2 == other.y2
15
+ end
16
+
17
+ def as_json
18
+ {
19
+ "x1" => x1,
20
+ "y1" => y1,
21
+ "x2" => x2,
22
+ "y2" => y2
23
+ }
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,6 @@
1
- require './lib/grid_generator/face_parser'
2
- require './lib/grid_generator/cubic/facing_square_factory'
1
+ require_relative '../face_parser'
2
+ require_relative '../base_element'
3
+ require_relative 'facing_square_factory'
3
4
 
4
5
  module GridGenerator
5
6
  module Cubic
@@ -73,23 +74,23 @@ module GridGenerator
73
74
 
74
75
  def rows
75
76
  Array.new(height) do |i|
76
- {
77
- "x1" => x,
78
- "y1" => unit_y(i+1),
79
- "x2" => max_x,
80
- "y2" => unit_y(i+1)
81
- }
77
+ GridGenerator::BaseLine.new(
78
+ x1: x,
79
+ y1: unit_y(i+1),
80
+ x2: max_x,
81
+ y2: unit_y(i+1)
82
+ )
82
83
  end
83
84
  end
84
85
 
85
86
  def columns
86
87
  Array.new(width) do |i|
87
- {
88
- "x1" => unit_x(i+1),
89
- "y1" => y,
90
- "x2" => unit_x(i+1),
91
- "y2" => max_y
92
- }
88
+ GridGenerator::BaseLine.new(
89
+ x1: unit_x(i+1),
90
+ y1: y,
91
+ x2: unit_x(i+1),
92
+ y2: max_y
93
+ )
93
94
  end
94
95
  end
95
96
 
@@ -1,5 +1,6 @@
1
- require './lib/grid_generator/face_parser'
2
- require './lib/grid_generator/cubic/facing_square_factory'
1
+ require_relative '../face_parser'
2
+ require_relative '../base_line'
3
+ require_relative 'facing_square_factory'
3
4
 
4
5
  module GridGenerator
5
6
  module Cubic
@@ -53,23 +54,23 @@ module GridGenerator
53
54
 
54
55
  def rows
55
56
  Array.new(height) do |i|
56
- {
57
- "x1" => x,
58
- "y1" => unit_y(i+1),
59
- "x2" => max_x,
60
- "y2" => unit_y(i+1)
61
- }
57
+ GridGenerator::BaseLine.new(
58
+ x1: x,
59
+ y1: unit_y(i+1),
60
+ x2: max_x,
61
+ y2: unit_y(i+1)
62
+ )
62
63
  end
63
64
  end
64
65
 
65
66
  def columns
66
67
  Array.new(width) do |i|
67
- {
68
- "x1" => unit_x(i+1),
69
- "y1" => y,
70
- "x2" => unit_x(i+1),
71
- "y2" => max_y
72
- }
68
+ GridGenerator::BaseLine.new(
69
+ x1: unit_x(i+1),
70
+ y1: y,
71
+ x2: unit_x(i+1),
72
+ y2: max_y
73
+ )
73
74
  end
74
75
  end
75
76
 
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/base_element'
1
+ require_relative '../base_element'
2
2
 
3
3
  module GridGenerator
4
4
  module Cubic
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/cubic/grid'
1
+ require_relative 'grid'
2
2
 
3
3
  module GridGenerator
4
4
  module Cubic
@@ -1,5 +1,6 @@
1
1
  require 'matrix'
2
- require './lib/grid_generator/face_parser'
2
+ require_relative '../face_parser'
3
+ require_relative '../base_line'
3
4
 
4
5
  module GridGenerator
5
6
  module Cubic
@@ -80,23 +81,23 @@ module GridGenerator
80
81
 
81
82
  def rows
82
83
  Array.new(height) do |i|
83
- {
84
- "x1" => row_line_start(i+1)[0,0],
85
- "y1" => row_line_start(i+1)[1,0],
86
- "x2" => row_line_end(i+1)[0,0],
87
- "y2" => row_line_end(i+1)[1,0]
88
- }
84
+ GridGenerator::BaseLine.new(
85
+ x1: row_line_start(i+1)[0,0],
86
+ y1: row_line_start(i+1)[1,0],
87
+ x2: row_line_end(i+1)[0,0],
88
+ y2: row_line_end(i+1)[1,0]
89
+ )
89
90
  end
90
91
  end
91
92
 
92
93
  def columns
93
94
  Array.new(width) do |i|
94
- {
95
- "x1" => column_line_start(i+1)[0,0],
96
- "y1" => column_line_start(i+1)[1,0],
97
- "x2" => column_line_end(i+1)[0,0],
98
- "y2" => column_line_end(i+1)[1,0]
99
- }
95
+ GridGenerator::BaseLine.new(
96
+ x1: column_line_start(i+1)[0,0],
97
+ y1: column_line_start(i+1)[1,0],
98
+ x2: column_line_end(i+1)[0,0],
99
+ y2: column_line_end(i+1)[1,0]
100
+ )
100
101
  end
101
102
  end
102
103
 
@@ -1,3 +1,7 @@
1
+ require_relative 'top_grid'
2
+ require_relative 'front_grid'
3
+ require_relative 'right_grid'
4
+
1
5
  module GridGenerator
2
6
  module Cubic
3
7
  class IsoView
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/cubic/grid'
1
+ require_relative 'grid'
2
2
 
3
3
  module GridGenerator
4
4
  module Cubic
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/base_element'
1
+ require_relative '../base_element'
2
2
 
3
3
  module GridGenerator
4
4
  module Cubic
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/cubic/grid'
1
+ require_relative 'grid'
2
2
 
3
3
  module GridGenerator
4
4
  module Cubic
@@ -1,4 +1,5 @@
1
1
  require 'matrix'
2
+
2
3
  module GridGenerator
3
4
  module Megaminx
4
5
  module Common
@@ -1,5 +1,5 @@
1
- require './lib/grid_generator/base_element'
2
- require './lib/grid_generator/megaminx/common'
1
+ require_relative '../base_element'
2
+ require_relative 'common'
3
3
 
4
4
  module GridGenerator
5
5
  module Megaminx
@@ -1,6 +1,6 @@
1
- require './lib/grid_generator/face_parser'
2
- require './lib/grid_generator/megaminx/common'
3
- require './lib/grid_generator/megaminx/element_factory'
1
+ require_relative '../face_parser'
2
+ require_relative 'common'
3
+ require_relative 'element_factory'
4
4
 
5
5
  module GridGenerator
6
6
  module Megaminx
@@ -1,4 +1,5 @@
1
- require './lib/grid_generator/pyraminx/triangle_factory'
1
+ require_relative '../base_line'
2
+ require_relative 'triangle_factory'
2
3
 
3
4
  module GridGenerator
4
5
  module Pyraminx
@@ -27,34 +28,34 @@ module GridGenerator
27
28
 
28
29
  def vertical_line_points
29
30
  Array.new((2*size)-1) do |i|
30
- {
31
- "x1" => x+((i+1)-size).abs*units,
32
- "y1" => y+(i+1)*units,
33
- "x2" => x+((((i+1)-size).abs*-1)+2*size)*units,
34
- "y2" => y+(i+1)*units
35
- }
31
+ GridGenerator::BaseLine.new(
32
+ x1: x+((i+1)-size).abs*units,
33
+ y1: y+(i+1)*units,
34
+ x2: x+((((i+1)-size).abs*-1)+2*size)*units,
35
+ y2: y+(i+1)*units
36
+ )
36
37
  end
37
38
  end
38
39
 
39
40
  def diagonal_down_line_points
40
41
  Array.new(size-1) do |i|
41
- {
42
- "x1" => x+((i-1).abs + 1)*units,
43
- "y1" => y+(i+1)*units,
44
- "x2" => x+((i-1).abs + 1 + size)*units,
45
- "y2" => y+(i+1+size)*units
46
- }
42
+ GridGenerator::BaseLine.new(
43
+ x1: x+((i-1).abs + 1)*units,
44
+ y1: y+(i+1)*units,
45
+ x2: x+((i-1).abs + 1 + size)*units,
46
+ y2: y+(i+1+size)*units
47
+ )
47
48
  end
48
49
  end
49
50
 
50
51
  def diagonal_up_line_points
51
52
  Array.new(size-1) do |i|
52
- {
53
- "x1" => x+(i+1)*units,
54
- "y1" => y+(i+1+size)*units,
55
- "x2" => x+(i+1+size)*units,
56
- "y2" => y+(i+1)*units
57
- }
53
+ GridGenerator::BaseLine.new(
54
+ x1: x+(i+1)*units,
55
+ y1: y+(i+1+size)*units,
56
+ x2: x+(i+1+size)*units,
57
+ y2: y+(i+1)*units
58
+ )
58
59
  end
59
60
  end
60
61
 
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/base_element'
1
+ require_relative '../base_element'
2
2
 
3
3
  module GridGenerator
4
4
  module Pyraminx
@@ -1,3 +1,5 @@
1
+ require_relative '../base_element'
2
+
1
3
  module GridGenerator
2
4
  module Skewb
3
5
  class LeftElementFactory
@@ -1,5 +1,6 @@
1
- require './lib/grid_generator/skewb/skewb_grid.rb'
2
- require './lib/grid_generator/skewb/left_element_factory.rb'
1
+ require_relative '../base_line'
2
+ require_relative 'skewb_grid'
3
+ require_relative 'left_element_factory'
3
4
 
4
5
  module GridGenerator
5
6
  module Skewb
@@ -19,23 +20,23 @@ module GridGenerator
19
20
 
20
21
  def rows
21
22
  Array.new(side_size) do |i|
22
- {
23
+ GridGenerator::BaseLine.new(
23
24
  x1: x + (2*i)*units,
24
25
  y1: y + (3*i+2)*units,
25
26
  x2: x + (2*i+2)*units,
26
27
  y2: y + (3*i+1)*units
27
- }
28
+ )
28
29
  end
29
30
  end
30
31
 
31
32
  def columns
32
33
  Array.new(side_size) do |i|
33
- {
34
+ GridGenerator::BaseLine.new(
34
35
  x1: x + (2*i)*units,
35
36
  y1: y + (-1*i+2)*units,
36
37
  x2: x + (i+1)*2*units,
37
38
  y2: y + (-1*i+5)*units
38
- }
39
+ )
39
40
  end
40
41
  end
41
42
  end
@@ -1,3 +1,5 @@
1
+ require_relative '../base_element'
2
+
1
3
  module GridGenerator
2
4
  module Skewb
3
5
  class RightElementFactory
@@ -1,5 +1,6 @@
1
- require './lib/grid_generator/skewb/skewb_grid.rb'
2
- require './lib/grid_generator/skewb/right_element_factory.rb'
1
+ require_relative '../base_element'
2
+ require_relative 'skewb_grid.rb'
3
+ require_relative 'right_element_factory.rb'
3
4
 
4
5
  module GridGenerator
5
6
  module Skewb
@@ -19,23 +20,23 @@ module GridGenerator
19
20
 
20
21
  def rows
21
22
  Array.new(side_size) do |i|
22
- {
23
+ GridGenerator::BaseLine.new(
23
24
  x1: x + (2*i)*units,
24
25
  y1: y + (i+4)*units,
25
26
  x2: x + (2*i+2)*units,
26
27
  y2: y + (i+1)*units
27
- }
28
+ )
28
29
  end
29
30
  end
30
31
 
31
32
  def columns
32
33
  Array.new(side_size) do |i|
33
- {
34
+ GridGenerator::BaseLine.new(
34
35
  x1: x + (2*i)*units,
35
36
  y1: y + (-3*i+4)*units,
36
37
  x2: x + (i+1)*2*units,
37
38
  y2: y + (-3*i+5)*units
38
- }
39
+ )
39
40
  end
40
41
  end
41
42
  end
@@ -1,4 +1,4 @@
1
- require './lib/grid_generator/face_parser'
1
+ require_relative '../face_parser'
2
2
 
3
3
  module GridGenerator
4
4
  module Skewb
@@ -1,3 +1,5 @@
1
+ require_relative '../base_element'
2
+
1
3
  module GridGenerator
2
4
  module Skewb
3
5
  class TopElementFactory
@@ -1,5 +1,6 @@
1
- require './lib/grid_generator/skewb/skewb_grid.rb'
2
- require './lib/grid_generator/skewb/top_element_factory.rb'
1
+ require_relative '../base_element'
2
+ require_relative 'skewb_grid'
3
+ require_relative 'top_element_factory'
3
4
 
4
5
  module GridGenerator
5
6
  module Skewb
@@ -19,23 +20,23 @@ module GridGenerator
19
20
 
20
21
  def rows
21
22
  Array.new(side_size) do |i|
22
- {
23
+ GridGenerator::BaseLine.new(
23
24
  x1: x + 2*units,
24
25
  y1: y + (2*i+1)*units,
25
26
  x2: x + 6*units,
26
27
  y2: y + (2*i+1)*units
27
- }
28
+ )
28
29
  end
29
30
  end
30
31
 
31
32
  def columns
32
33
  Array.new(side_size) do |i|
33
- {
34
+ GridGenerator::BaseLine.new(
34
35
  x1: x + (4*i+2)*units,
35
36
  y1: y + units,
36
37
  x2: x + (4*i+2)*units,
37
38
  y2: y + 3*units
38
- }
39
+ )
39
40
  end
40
41
  end
41
42
  end
@@ -1,5 +1,5 @@
1
1
  require 'matrix'
2
- require './lib/grid_generator/base_element'
2
+ require_relative '../base_element'
3
3
 
4
4
  module GridGenerator
5
5
  module SquareOne
@@ -1,5 +1,6 @@
1
- require './lib/grid_generator/square_one_face_parser'
2
- require './lib/grid_generator/square_one/element_factory'
1
+ require_relative '../base_line'
2
+ require_relative '../square_one_face_parser'
3
+ require_relative 'element_factory'
3
4
 
4
5
  module GridGenerator
5
6
  module SquareOne
@@ -41,21 +42,21 @@ module GridGenerator
41
42
  end
42
43
 
43
44
  def forward_axis
44
- {
45
+ GridGenerator::BaseLine.new(
45
46
  x1: x+half_face_size+half_edge_width,
46
47
  y1: y,
47
48
  x2: x+half_face_size-half_edge_width,
48
49
  y2: y+face_size
49
- }
50
+ )
50
51
  end
51
52
 
52
53
  def back_axis
53
- {
54
+ GridGenerator::BaseLine.new(
54
55
  x1: x+half_face_size-half_edge_width,
55
56
  y1: y,
56
57
  x2: x+half_face_size+half_edge_width,
57
58
  y2: y+face_size
58
- }
59
+ )
59
60
  end
60
61
 
61
62
  def element_shapes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GridGenerator
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -2,23 +2,23 @@
2
2
 
3
3
  require_relative "grid_generator/version"
4
4
 
5
- require './lib/grid_generator/cubic/iso_view.rb'
6
- require './lib/grid_generator/cubic/top_grid'
7
- require './lib/grid_generator/cubic/front_grid'
8
- require './lib/grid_generator/cubic/right_grid'
9
- require './lib/grid_generator/cubic/facing_grid'
10
- require './lib/grid_generator/cubic/bordered_grid'
11
- require './lib/grid_generator/cubic/square_factory'
12
- require './lib/grid_generator/skewb/top_skewb_grid'
13
- require './lib/grid_generator/skewb/left_skewb_grid'
14
- require './lib/grid_generator/skewb/right_skewb_grid'
15
- require './lib/grid_generator/square_one/face'
16
- require './lib/grid_generator/arrows/vertical_arrow'
17
- require './lib/grid_generator/arrows/horizontal_arrow'
18
- require './lib/grid_generator/arrows/diagonal_down_arrow'
19
- require './lib/grid_generator/arrows/diagonal_up_arrow'
20
- require './lib/grid_generator/pyraminx/grid'
21
- require './lib/grid_generator/megaminx/face'
5
+ require_relative 'grid_generator/cubic/iso_view'
6
+ require_relative 'grid_generator/cubic/top_grid'
7
+ require_relative 'grid_generator/cubic/front_grid'
8
+ require_relative 'grid_generator/cubic/right_grid'
9
+ require_relative 'grid_generator/cubic/facing_grid'
10
+ require_relative 'grid_generator/cubic/bordered_grid'
11
+ require_relative 'grid_generator/cubic/square_factory'
12
+ require_relative 'grid_generator/skewb/top_skewb_grid'
13
+ require_relative 'grid_generator/skewb/left_skewb_grid'
14
+ require_relative 'grid_generator/skewb/right_skewb_grid'
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
+ require_relative 'grid_generator/pyraminx/grid'
21
+ require_relative 'grid_generator/megaminx/face'
22
22
 
23
23
  module GridGenerator
24
24
  def self.iso_view(args)
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.1.0
4
+ version: 0.1.2
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-02-23 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: matrix
@@ -46,6 +46,7 @@ files:
46
46
  - lib/grid_generator/arrows/horizontal_arrow.rb
47
47
  - lib/grid_generator/arrows/vertical_arrow.rb
48
48
  - lib/grid_generator/base_element.rb
49
+ - lib/grid_generator/base_line.rb
49
50
  - lib/grid_generator/cubic/bordered_grid.rb
50
51
  - lib/grid_generator/cubic/facing_grid.rb
51
52
  - lib/grid_generator/cubic/facing_square_factory.rb
@@ -68,7 +69,6 @@ files:
68
69
  - lib/grid_generator/skewb/skewb_grid.rb
69
70
  - lib/grid_generator/skewb/top_element_factory.rb
70
71
  - lib/grid_generator/skewb/top_skewb_grid.rb
71
- - lib/grid_generator/square_one/element.rb
72
72
  - lib/grid_generator/square_one/element_factory.rb
73
73
  - lib/grid_generator/square_one/face.rb
74
74
  - lib/grid_generator/square_one_face_parser.rb
@@ -1,60 +0,0 @@
1
- require 'matrix'
2
-
3
- module GridGenerator
4
- module SquareOne
5
- class Element
6
- def initialize(x:, y:, units:, offset: , colour: , opacity: )
7
- @x, @y = x, y
8
- @units = units
9
- @offset = offset
10
- @colour = colour
11
- @opacity = opacity
12
- end
13
-
14
- attr_reader :x, :y, :units, :offset, :colour, :opacity
15
-
16
- def ==(other)
17
- self.x == other.x &&
18
- self.y == other.y &&
19
- self.units == other.units &&
20
- self.colour == other.colour &&
21
- self.opacity == other.opacity
22
- end
23
-
24
- def offset_radians
25
- offset*Math::PI/6
26
- end
27
-
28
- def half_edge_width
29
- @half_edge_width ||= half_face_size * Math.tan(Math::PI/12)
30
- end
31
-
32
- def half_face_size
33
- @half_face_size ||= face_size / 2
34
- end
35
-
36
- def face_size
37
- @face_size ||= 3 * units
38
- end
39
-
40
- def rotation_point
41
- Matrix.column_vector([x+half_face_size, y+half_face_size])
42
- end
43
-
44
- def rotation_matrix
45
- @rotation_matrix ||= Matrix[
46
- [Math.cos(offset_radians), -1*Math.sin(offset_radians)],
47
- [Math.sin(offset_radians), Math.cos(offset_radians)]
48
- ]
49
- end
50
-
51
- def points
52
- base_points.map { |p| (rotation_matrix * (p - rotation_point)) + rotation_point }
53
- end
54
-
55
- def points_string
56
- points.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
57
- end
58
- end
59
- end
60
- end