grid_generator 0.4.1 → 0.4.3
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/face_parser.rb +3 -1
- data/lib/grid_generator/skewb/element_factory.rb +64 -0
- data/lib/grid_generator/skewb/left_element_factory.rb +13 -84
- data/lib/grid_generator/skewb/right_element_factory.rb +13 -84
- data/lib/grid_generator/skewb/top_element_factory.rb +13 -84
- data/lib/grid_generator/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f508eb8be3c5faf020a8a31064216c49e34046e9e468433782f479d1d6bd1a
|
4
|
+
data.tar.gz: 9327c8988103c0329d7171a246c94bc145eda322413369d51baba69c6d886d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f06f1c22ecaf76302623b9aa83f6a9243a33de1e536d74f74d580ec195ee0a1678686a2b1a328ee971e30d095a049980579b273f9fcde0723326281a6c2f3e48
|
7
|
+
data.tar.gz: 8edf5c1bc14469b59314a47ee72eb75a7c92db5646f3bf05dfbe7e32d8b48eaec90dd3d25b08236be9b0eeb7432b51ee7f8ca6eff2a35cc3a6178f3ef30e29c2
|
data/Gemfile.lock
CHANGED
@@ -9,10 +9,12 @@ module GridGenerator
|
|
9
9
|
'o' => '#ffb000',
|
10
10
|
'gr' => '#808080',
|
11
11
|
'br' => '#804000',
|
12
|
-
's' => '#
|
12
|
+
's' => '#c2b280',
|
13
|
+
'c' => '#00ffff',
|
13
14
|
'l' => '#80ff80',
|
14
15
|
'p' => '#800080',
|
15
16
|
'pi' => '#ff8080',
|
17
|
+
'bl' => '#404040',
|
16
18
|
'fu' => "#f0f0f0", # face up
|
17
19
|
'ff' => "#d0d0d0", # face front
|
18
20
|
'fr' => "#b0b0b0" # face right
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'matrix'
|
2
|
+
require_relative '../base_element'
|
3
|
+
|
4
|
+
module GridGenerator
|
5
|
+
module Skewb
|
6
|
+
class ElementFactory
|
7
|
+
def initialize(grid_x:, grid_y:, row_num:, col_num:, side_size:, units:, colour:, opacity:)
|
8
|
+
@grid_x, @grid_y = grid_x, grid_y
|
9
|
+
@row_num, @col_num = row_num, col_num
|
10
|
+
@side_size, @units = side_size, units
|
11
|
+
@colour, @opacity = colour, opacity
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :grid_x, :grid_y, :row_num, :col_num, :side_size, :units, :colour, :opacity
|
15
|
+
|
16
|
+
def offset
|
17
|
+
@offset ||= Matrix.column_vector([grid_x, grid_y])
|
18
|
+
end
|
19
|
+
|
20
|
+
def points
|
21
|
+
_points = case [row_num, col_num]
|
22
|
+
when [0, 0] # top left corner
|
23
|
+
[
|
24
|
+
anchors[:top_left_corner],
|
25
|
+
anchors[:top_middle],
|
26
|
+
anchors[:left_middle]
|
27
|
+
]
|
28
|
+
when [0, 2] # top right corner
|
29
|
+
[
|
30
|
+
anchors[:top_middle],
|
31
|
+
anchors[:top_right_corner],
|
32
|
+
anchors[:right_middle]
|
33
|
+
]
|
34
|
+
when [1, 1] # center
|
35
|
+
[
|
36
|
+
anchors[:top_middle],
|
37
|
+
anchors[:right_middle],
|
38
|
+
anchors[:bottom_middle],
|
39
|
+
anchors[:left_middle]
|
40
|
+
]
|
41
|
+
when [2, 0] # bottom left corner
|
42
|
+
[
|
43
|
+
anchors[:left_middle],
|
44
|
+
anchors[:bottom_middle],
|
45
|
+
anchors[:bottom_left_corner]
|
46
|
+
]
|
47
|
+
when [2, 2] # bottom right corner
|
48
|
+
[
|
49
|
+
anchors[:right_middle],
|
50
|
+
anchors[:bottom_right_corner],
|
51
|
+
anchors[:bottom_middle]
|
52
|
+
]
|
53
|
+
else
|
54
|
+
[]
|
55
|
+
end
|
56
|
+
_points.map { |p| p + offset }
|
57
|
+
end
|
58
|
+
|
59
|
+
def build
|
60
|
+
GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,91 +1,20 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './element_factory'
|
2
2
|
|
3
3
|
module GridGenerator
|
4
4
|
module Skewb
|
5
|
-
class LeftElementFactory
|
6
|
-
def
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
attr_reader :grid_x, :grid_y, :row_num, :col_num, :side_size, :units, :colour, :opacity
|
14
|
-
|
15
|
-
def x
|
16
|
-
@x ||= case [row_num, col_num]
|
17
|
-
when [0, 0] # Left Up
|
18
|
-
grid_x
|
19
|
-
when [0, side_size] # Left Front
|
20
|
-
grid_x+(side_size-1)*2*units
|
21
|
-
when [side_size, 0] # Left Left
|
22
|
-
grid_x
|
23
|
-
when [side_size, side_size] # Left Down
|
24
|
-
grid_x+(side_size-1)*2*units
|
25
|
-
when [(side_size/2),(side_size/2)] # Left Center
|
26
|
-
grid_x
|
27
|
-
else
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def y
|
33
|
-
@y ||= case [row_num, col_num]
|
34
|
-
when [0, 0] # Left Up
|
35
|
-
grid_y
|
36
|
-
when [0, side_size] # Left Front
|
37
|
-
grid_y+(side_size-1)*units
|
38
|
-
when [side_size, 0] # Left Left
|
39
|
-
grid_y+(side_size-1)*2*units
|
40
|
-
when [side_size, side_size] # Left Down
|
41
|
-
grid_y+(side_size)*2*units
|
42
|
-
when [(side_size/2),(side_size/2)] # Left Center
|
43
|
-
grid_y+(side_size/2)*units
|
44
|
-
else
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def points
|
50
|
-
case [row_num, col_num]
|
51
|
-
when [0, 0] # Left Up
|
52
|
-
[
|
53
|
-
Matrix.column_vector([ x, y ]),
|
54
|
-
Matrix.column_vector([ x+2*units, y+units ]),
|
55
|
-
Matrix.column_vector([ x, y+2*units ])
|
56
|
-
]
|
57
|
-
when [0, side_size] # Left Front
|
58
|
-
[
|
59
|
-
Matrix.column_vector([ x, y ]),
|
60
|
-
Matrix.column_vector([ x+2*units, y+units ]),
|
61
|
-
Matrix.column_vector([ x+2*units, y+3*units ])
|
62
|
-
]
|
63
|
-
when [side_size, 0] # Left Left
|
64
|
-
[
|
65
|
-
Matrix.column_vector([ x, y ]),
|
66
|
-
Matrix.column_vector([ x+2*units, y+3*units ]),
|
67
|
-
Matrix.column_vector([ x, y+2*units ])
|
68
|
-
]
|
69
|
-
when [side_size, side_size] # Left Down
|
70
|
-
[
|
71
|
-
Matrix.column_vector([ x+2*units, y ]),
|
72
|
-
Matrix.column_vector([ x+2*units, y+2*units ]),
|
73
|
-
Matrix.column_vector([ x, y+units ])
|
74
|
-
]
|
75
|
-
when [(side_size/2), (side_size/2)] # Left Center
|
76
|
-
[
|
77
|
-
Matrix.column_vector([ x+2*units, y ]),
|
78
|
-
Matrix.column_vector([ x+4*units, y+3*units ]),
|
79
|
-
Matrix.column_vector([ x+2*units, y+4*units ]),
|
80
|
-
Matrix.column_vector([ x, y+units ])
|
81
|
-
]
|
82
|
-
else
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
end
|
5
|
+
class LeftElementFactory < ElementFactory
|
6
|
+
def anchors
|
7
|
+
@anchors ||= {
|
8
|
+
top_left_corner: Matrix.column_vector([0, 0]),
|
9
|
+
top_right_corner: Matrix.column_vector([4*units, 2*units]),
|
10
|
+
bottom_left_corner: Matrix.column_vector([0, 4*units]),
|
11
|
+
bottom_right_corner: Matrix.column_vector([4*units, 6*units]),
|
86
12
|
|
87
|
-
|
88
|
-
|
13
|
+
top_middle: Matrix.column_vector([2*units, units]),
|
14
|
+
left_middle: Matrix.column_vector([0, 2*units]),
|
15
|
+
right_middle: Matrix.column_vector([4*units, 4*units]),
|
16
|
+
bottom_middle: Matrix.column_vector([2*units, 5*units])
|
17
|
+
}
|
89
18
|
end
|
90
19
|
end
|
91
20
|
end
|
@@ -1,91 +1,20 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './element_factory'
|
2
2
|
|
3
3
|
module GridGenerator
|
4
4
|
module Skewb
|
5
|
-
class RightElementFactory
|
6
|
-
def
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
attr_reader :grid_x, :grid_y, :row_num, :col_num, :side_size, :units, :colour, :opacity
|
14
|
-
|
15
|
-
def x
|
16
|
-
@x ||= case [row_num, col_num]
|
17
|
-
when [0, 0] # Right Front
|
18
|
-
grid_x
|
19
|
-
when [0, side_size] # Right Up
|
20
|
-
grid_x+(side_size-1)*2*units
|
21
|
-
when [side_size, 0] # Right Down
|
22
|
-
grid_x
|
23
|
-
when [side_size, side_size] # Right Right
|
24
|
-
grid_x+(side_size-1)*2*units
|
25
|
-
when [(side_size/2),(side_size/2)] # Right Center
|
26
|
-
grid_x
|
27
|
-
else
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def y
|
33
|
-
@y ||= case [row_num, col_num]
|
34
|
-
when [0, 0] # Right Front
|
35
|
-
grid_y+(side_size-1)*units
|
36
|
-
when [0, side_size] # Right Up
|
37
|
-
grid_y
|
38
|
-
when [side_size, 0] # Right Down
|
39
|
-
grid_y+(2*side_size)*units
|
40
|
-
when [side_size, side_size] # Right Right
|
41
|
-
grid_y+(side_size-1)*2*units
|
42
|
-
when [(side_size/2),(side_size/2)] # Right Center
|
43
|
-
grid_y+(side_size/2)*units
|
44
|
-
else
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def points
|
50
|
-
case [row_num, col_num]
|
51
|
-
when [0, 0] # Right Front
|
52
|
-
[
|
53
|
-
Matrix.column_vector([ x, y+units ]),
|
54
|
-
Matrix.column_vector([ x+2*units, y ]),
|
55
|
-
Matrix.column_vector([ x, y+3*units ])
|
56
|
-
]
|
57
|
-
when [0, side_size] # Right Up
|
58
|
-
[
|
59
|
-
Matrix.column_vector([ x, y+units ]),
|
60
|
-
Matrix.column_vector([ x+2*units, y ]),
|
61
|
-
Matrix.column_vector([ x+2*units, y+2*units ])
|
62
|
-
]
|
63
|
-
when [side_size, 0] # Right Down
|
64
|
-
[
|
65
|
-
Matrix.column_vector([ x, y ]),
|
66
|
-
Matrix.column_vector([ x+2*units, y+units ]),
|
67
|
-
Matrix.column_vector([ x, y+2*units ])
|
68
|
-
]
|
69
|
-
when [side_size, side_size] # Right Right
|
70
|
-
[
|
71
|
-
Matrix.column_vector([ x+2*units, y ]),
|
72
|
-
Matrix.column_vector([ x+2*units, y+2*units ]),
|
73
|
-
Matrix.column_vector([ x, y+3*units ])
|
74
|
-
]
|
75
|
-
when [(side_size/2), (side_size/2)] # Right Center
|
76
|
-
[
|
77
|
-
Matrix.column_vector([ x+2*units, y ]),
|
78
|
-
Matrix.column_vector([ x+4*units, y+units ]),
|
79
|
-
Matrix.column_vector([ x+2*units, y+4*units ]),
|
80
|
-
Matrix.column_vector([ x, y+3*units ])
|
81
|
-
]
|
82
|
-
else
|
83
|
-
[]
|
84
|
-
end
|
85
|
-
end
|
5
|
+
class RightElementFactory < ElementFactory
|
6
|
+
def anchors
|
7
|
+
@anchors ||= {
|
8
|
+
top_left_corner: Matrix.column_vector([0, 2*units]),
|
9
|
+
top_right_corner: Matrix.column_vector([4*units, 0]),
|
10
|
+
bottom_left_corner: Matrix.column_vector([0, 6*units]),
|
11
|
+
bottom_right_corner: Matrix.column_vector([4*units, 4*units]),
|
86
12
|
|
87
|
-
|
88
|
-
|
13
|
+
top_middle: Matrix.column_vector([2*units, units]),
|
14
|
+
left_middle: Matrix.column_vector([0, 4*units]),
|
15
|
+
right_middle: Matrix.column_vector([4*units, 2*units]),
|
16
|
+
bottom_middle: Matrix.column_vector([2*units, 5*units])
|
17
|
+
}
|
89
18
|
end
|
90
19
|
end
|
91
20
|
end
|
@@ -1,91 +1,20 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './element_factory'
|
2
2
|
|
3
3
|
module GridGenerator
|
4
4
|
module Skewb
|
5
|
-
class TopElementFactory
|
6
|
-
def
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
attr_reader :grid_x, :grid_y, :row_num, :col_num, :side_size, :units, :colour, :opacity
|
14
|
-
|
15
|
-
def x
|
16
|
-
@x ||= case [row_num, col_num]
|
17
|
-
when [0, 0] # Top Back
|
18
|
-
grid_x+(side_size-1)*2*units
|
19
|
-
when [0, side_size] # Top Right
|
20
|
-
grid_x+((side_size*2)-1)*2*units
|
21
|
-
when [side_size, 0] # Top Left
|
22
|
-
grid_x
|
23
|
-
when [side_size, side_size] # Top Front
|
24
|
-
grid_x+(side_size-1)*2*units
|
25
|
-
when [(side_size/2),(side_size/2)] # Top Center
|
26
|
-
grid_x+(side_size/2)*2*units
|
27
|
-
else
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def y
|
33
|
-
@y ||= case [row_num, col_num]
|
34
|
-
when [0, 0] # Top Back
|
35
|
-
grid_y
|
36
|
-
when [0, side_size] # Top Right
|
37
|
-
grid_y+(side_size-1)*units
|
38
|
-
when [side_size, 0] # Top Left
|
39
|
-
grid_y+(side_size-1)*units
|
40
|
-
when [side_size, side_size] # Top Front
|
41
|
-
grid_y+(side_size*2-1)*units
|
42
|
-
when [(side_size/2),(side_size/2)] # Top Center
|
43
|
-
grid_y+(side_size/2)*units
|
44
|
-
else
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def points
|
50
|
-
case [row_num, col_num]
|
51
|
-
when [0, 0] # Top Back
|
52
|
-
[
|
53
|
-
Matrix.column_vector([ x+2*units, y ]),
|
54
|
-
Matrix.column_vector([ x+4*units, y+units ]),
|
55
|
-
Matrix.column_vector([ x, y+units ])
|
56
|
-
]
|
57
|
-
when [0, side_size] # Top Right
|
58
|
-
[
|
59
|
-
Matrix.column_vector([ x, y ]),
|
60
|
-
Matrix.column_vector([ x+2*units, y+units ]),
|
61
|
-
Matrix.column_vector([ x, y+2*units ])
|
62
|
-
]
|
63
|
-
when [side_size, 0] # Top Left
|
64
|
-
[
|
65
|
-
Matrix.column_vector([ x+2*units, y ]),
|
66
|
-
Matrix.column_vector([ x+2*units, y+2*units ]),
|
67
|
-
Matrix.column_vector([ x, y+units ])
|
68
|
-
]
|
69
|
-
when [side_size, side_size] # Top Front
|
70
|
-
[
|
71
|
-
Matrix.column_vector([ x, y ]),
|
72
|
-
Matrix.column_vector([ x+4*units, y ]),
|
73
|
-
Matrix.column_vector([ x+2*units, y+units ])
|
74
|
-
]
|
75
|
-
when [(side_size/2), (side_size/2)] # Top Center
|
76
|
-
[
|
77
|
-
Matrix.column_vector([ x, y ]),
|
78
|
-
Matrix.column_vector([ x+4*units, y ]),
|
79
|
-
Matrix.column_vector([ x+4*units, y+2*units ]),
|
80
|
-
Matrix.column_vector([ x, y+2*units ])
|
81
|
-
]
|
82
|
-
else
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
end
|
5
|
+
class TopElementFactory < ElementFactory
|
6
|
+
def anchors
|
7
|
+
@anchors ||= {
|
8
|
+
top_left_corner: Matrix.column_vector([4*units, 0]),
|
9
|
+
top_right_corner: Matrix.column_vector([8*units, 2*units]),
|
10
|
+
bottom_left_corner: Matrix.column_vector([0, 2*units]),
|
11
|
+
bottom_right_corner: Matrix.column_vector([4*units, 4*units]),
|
86
12
|
|
87
|
-
|
88
|
-
|
13
|
+
top_middle: Matrix.column_vector([6*units, units]),
|
14
|
+
left_middle: Matrix.column_vector([2*units, units]),
|
15
|
+
right_middle: Matrix.column_vector([6*units, 3*units]),
|
16
|
+
bottom_middle: Matrix.column_vector([2*units, 3*units])
|
17
|
+
}
|
89
18
|
end
|
90
19
|
end
|
91
20
|
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.
|
4
|
+
version: 0.4.3
|
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-05-
|
11
|
+
date: 2023-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matrix
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/grid_generator/pyraminx/triangle_factory.rb
|
69
69
|
- lib/grid_generator/rotator.rb
|
70
70
|
- lib/grid_generator/scaler.rb
|
71
|
+
- lib/grid_generator/skewb/element_factory.rb
|
71
72
|
- lib/grid_generator/skewb/left_element_factory.rb
|
72
73
|
- lib/grid_generator/skewb/left_skewb_grid.rb
|
73
74
|
- lib/grid_generator/skewb/right_element_factory.rb
|