grid_generator 0.1.3 → 0.1.5
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/arrows/diagonal_down_arrow.rb +14 -56
- data/lib/grid_generator/arrows/diagonal_up_arrow.rb +14 -56
- data/lib/grid_generator/arrows/horizontal_arrow.rb +14 -56
- data/lib/grid_generator/arrows/vertical_arrow.rb +14 -56
- data/lib/grid_generator/cubic/bordered_grid.rb +1 -1
- data/lib/grid_generator/cubic/facing_grid.rb +1 -1
- data/lib/grid_generator/cubic/front_grid.rb +3 -10
- data/lib/grid_generator/cubic/grid.rb +15 -5
- data/lib/grid_generator/cubic/right_grid.rb +3 -11
- data/lib/grid_generator/cubic/square_factory.rb +9 -6
- data/lib/grid_generator/cubic/top_grid.rb +3 -10
- data/lib/grid_generator/cubic/units_factory.rb +60 -0
- data/lib/grid_generator/face_parser.rb +29 -10
- data/lib/grid_generator/megaminx/face.rb +1 -1
- data/lib/grid_generator/skewb/skewb_grid.rb +1 -1
- data/lib/grid_generator/version.rb +1 -1
- data/lib/grid_generator.rb +13 -25
- 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: 4ca39eb693f9a8ef806c69a8ad9293912e5f1a8699962939b1a92a2ae644e2cb
|
|
4
|
+
data.tar.gz: d59e8615cb32f345f745f99cb282d324f9253966a0e08c14c5c30868c4e6a670
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87926ed9d36e9255069fa6b8c16fcf5e310ad283806da1fbe150c574208b32c52f5ba48159092ab0cf38fbdc39ffb1ecbe215602a89729997378c3a261e6a3a7
|
|
7
|
+
data.tar.gz: c3d6c72ce540b0fe1c265181a74f549a4d2c9fc87de23bf07c33f12d7d8b06e315329ddc9aaac69393c23e3c0129fd2cd0355638b95879a0736a0dbd5af4f6d4
|
data/Gemfile.lock
CHANGED
|
@@ -8,87 +8,45 @@ module GridGenerator
|
|
|
8
8
|
|
|
9
9
|
def arrow_start_point
|
|
10
10
|
[
|
|
11
|
-
[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
],
|
|
15
|
-
[
|
|
16
|
-
x,
|
|
17
|
-
y
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
x+ARROW_SIDE,
|
|
21
|
-
y
|
|
22
|
-
]
|
|
11
|
+
[ x, y+ARROW_SIDE ],
|
|
12
|
+
[ x, y ],
|
|
13
|
+
[ x+ARROW_SIDE, y ]
|
|
23
14
|
]
|
|
24
15
|
end
|
|
25
16
|
|
|
26
17
|
def arrow_start_flat
|
|
27
18
|
[
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
y+ARROW_SIDE-(2*ARROW_OVERHANG)
|
|
31
|
-
],
|
|
32
|
-
[
|
|
33
|
-
x+ARROW_SIDE-(2*ARROW_OVERHANG),
|
|
34
|
-
y
|
|
35
|
-
]
|
|
19
|
+
[ x, y+ARROW_SIDE-(2*ARROW_OVERHANG) ],
|
|
20
|
+
[ x+ARROW_SIDE-(2*ARROW_OVERHANG), y ]
|
|
36
21
|
]
|
|
37
22
|
end
|
|
38
23
|
|
|
39
24
|
def arrow_start_side
|
|
40
25
|
[
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
y+ARROW_OVERHANG
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
x+(ARROW_SIDE-ARROW_OVERHANG)+length,
|
|
47
|
-
y+length+ARROW_OVERHANG
|
|
48
|
-
]
|
|
26
|
+
[ x+ARROW_SIDE-ARROW_OVERHANG, y+ARROW_OVERHANG ],
|
|
27
|
+
[ x+(ARROW_SIDE-ARROW_OVERHANG)+length, y+length+ARROW_OVERHANG ]
|
|
49
28
|
]
|
|
50
29
|
end
|
|
51
30
|
|
|
52
31
|
def arrow_end_point
|
|
53
32
|
[
|
|
54
|
-
[
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
x+ARROW_SIDE+length,
|
|
60
|
-
y+ARROW_SIDE+length
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
x+length,
|
|
64
|
-
y+ARROW_SIDE+length
|
|
65
|
-
]
|
|
33
|
+
[ x+ARROW_SIDE+length, y+length ],
|
|
34
|
+
[ x+ARROW_SIDE+length, y+ARROW_SIDE+length ],
|
|
35
|
+
[ x+length, y+ARROW_SIDE+length ]
|
|
66
36
|
]
|
|
67
37
|
end
|
|
68
38
|
|
|
69
39
|
def arrow_end_flat
|
|
70
40
|
[
|
|
71
|
-
[
|
|
72
|
-
|
|
73
|
-
y+length+(2*ARROW_OVERHANG)
|
|
74
|
-
],
|
|
75
|
-
[
|
|
76
|
-
x+length+(2*ARROW_OVERHANG),
|
|
77
|
-
y+ARROW_SIDE+length
|
|
78
|
-
]
|
|
41
|
+
[ x+ARROW_SIDE+length, y+length+(2*ARROW_OVERHANG) ],
|
|
42
|
+
[ x+length+(2*ARROW_OVERHANG), y+ARROW_SIDE+length ]
|
|
79
43
|
]
|
|
80
44
|
end
|
|
81
45
|
|
|
82
46
|
def arrow_end_side
|
|
83
47
|
[
|
|
84
|
-
[
|
|
85
|
-
|
|
86
|
-
y+ARROW_SIDE+length-ARROW_OVERHANG
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
x+ARROW_OVERHANG,
|
|
90
|
-
y+ARROW_SIDE-ARROW_OVERHANG
|
|
91
|
-
]
|
|
48
|
+
[ x+length+ARROW_OVERHANG, y+ARROW_SIDE+length-ARROW_OVERHANG ],
|
|
49
|
+
[ x+ARROW_OVERHANG, y+ARROW_SIDE-ARROW_OVERHANG ]
|
|
92
50
|
]
|
|
93
51
|
end
|
|
94
52
|
|
|
@@ -8,87 +8,45 @@ module GridGenerator
|
|
|
8
8
|
|
|
9
9
|
def arrow_start_point
|
|
10
10
|
[
|
|
11
|
-
[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
],
|
|
15
|
-
[
|
|
16
|
-
x,
|
|
17
|
-
y+length+ARROW_SIDE
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
x,
|
|
21
|
-
y+length
|
|
22
|
-
]
|
|
11
|
+
[ x+ARROW_SIDE, y+length+ARROW_SIDE ],
|
|
12
|
+
[ x, y+length+ARROW_SIDE ],
|
|
13
|
+
[ x, y+length ]
|
|
23
14
|
]
|
|
24
15
|
end
|
|
25
16
|
|
|
26
17
|
def arrow_start_flat
|
|
27
18
|
[
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
y+length+ARROW_SIDE
|
|
31
|
-
],
|
|
32
|
-
[
|
|
33
|
-
x,
|
|
34
|
-
y+length+(2*ARROW_OVERHANG)
|
|
35
|
-
]
|
|
19
|
+
[ x+ARROW_SIDE-(2*ARROW_OVERHANG), y+length+ARROW_SIDE ],
|
|
20
|
+
[ x, y+length+(2*ARROW_OVERHANG) ]
|
|
36
21
|
]
|
|
37
22
|
end
|
|
38
23
|
|
|
39
24
|
def arrow_start_side
|
|
40
25
|
[
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
y+length+ARROW_OVERHANG
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
x+length+ARROW_OVERHANG,
|
|
47
|
-
y+ARROW_OVERHANG
|
|
48
|
-
]
|
|
26
|
+
[ x+ARROW_OVERHANG, y+length+ARROW_OVERHANG ],
|
|
27
|
+
[ x+length+ARROW_OVERHANG, y+ARROW_OVERHANG ]
|
|
49
28
|
]
|
|
50
29
|
end
|
|
51
30
|
|
|
52
31
|
def arrow_end_point
|
|
53
32
|
[
|
|
54
|
-
[
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
x+length+ARROW_SIDE,
|
|
60
|
-
y
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
x+length+ARROW_SIDE,
|
|
64
|
-
y+ARROW_SIDE
|
|
65
|
-
]
|
|
33
|
+
[ x+length, y ],
|
|
34
|
+
[ x+length+ARROW_SIDE, y ],
|
|
35
|
+
[ x+length+ARROW_SIDE, y+ARROW_SIDE ]
|
|
66
36
|
]
|
|
67
37
|
end
|
|
68
38
|
|
|
69
39
|
def arrow_end_flat
|
|
70
40
|
[
|
|
71
|
-
[
|
|
72
|
-
|
|
73
|
-
y
|
|
74
|
-
],
|
|
75
|
-
[
|
|
76
|
-
x+length+ARROW_SIDE,
|
|
77
|
-
y+ARROW_SIDE-(2*ARROW_OVERHANG)
|
|
78
|
-
]
|
|
41
|
+
[ x+length+(2*ARROW_OVERHANG), y ],
|
|
42
|
+
[ x+length+ARROW_SIDE, y+ARROW_SIDE-(2*ARROW_OVERHANG) ]
|
|
79
43
|
]
|
|
80
44
|
end
|
|
81
45
|
|
|
82
46
|
def arrow_end_side
|
|
83
47
|
[
|
|
84
|
-
[
|
|
85
|
-
|
|
86
|
-
y+ARROW_SIDE-ARROW_OVERHANG
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
x+ARROW_SIDE-ARROW_OVERHANG,
|
|
90
|
-
y+length+ARROW_SIDE-ARROW_OVERHANG
|
|
91
|
-
]
|
|
48
|
+
[ x+length+ARROW_SIDE-ARROW_OVERHANG, y+ARROW_SIDE-ARROW_OVERHANG ],
|
|
49
|
+
[ x+ARROW_SIDE-ARROW_OVERHANG, y+length+ARROW_SIDE-ARROW_OVERHANG ]
|
|
92
50
|
]
|
|
93
51
|
end
|
|
94
52
|
|
|
@@ -9,87 +9,45 @@ module GridGenerator
|
|
|
9
9
|
|
|
10
10
|
def arrow_start_point
|
|
11
11
|
[
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
],
|
|
16
|
-
[
|
|
17
|
-
x,
|
|
18
|
-
y+(ARROW_WIDTH/2)
|
|
19
|
-
],
|
|
20
|
-
[
|
|
21
|
-
x+ARROW_LENGTH,
|
|
22
|
-
y
|
|
23
|
-
]
|
|
12
|
+
[ x+ARROW_LENGTH, y+ARROW_WIDTH ],
|
|
13
|
+
[ x, y+(ARROW_WIDTH/2) ],
|
|
14
|
+
[ x+ARROW_LENGTH, y ]
|
|
24
15
|
]
|
|
25
16
|
end
|
|
26
17
|
|
|
27
18
|
def arrow_start_flat
|
|
28
19
|
[
|
|
29
|
-
[
|
|
30
|
-
|
|
31
|
-
y+(ARROW_WIDTH/2)+(LINE_WIDTH/2)
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
x,
|
|
35
|
-
y+(ARROW_WIDTH/2)-(LINE_WIDTH/2)
|
|
36
|
-
]
|
|
20
|
+
[ x, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ],
|
|
21
|
+
[ x, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ]
|
|
37
22
|
]
|
|
38
23
|
end
|
|
39
24
|
|
|
40
25
|
def arrow_start_side
|
|
41
26
|
[
|
|
42
|
-
[
|
|
43
|
-
|
|
44
|
-
y+(ARROW_WIDTH/2)-(LINE_WIDTH/2)
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
x+ARROW_LENGTH+length,
|
|
48
|
-
y+(ARROW_WIDTH/2)-(LINE_WIDTH/2)
|
|
49
|
-
]
|
|
27
|
+
[ x+ARROW_LENGTH, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ],
|
|
28
|
+
[ x+ARROW_LENGTH+length, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ]
|
|
50
29
|
]
|
|
51
30
|
end
|
|
52
31
|
|
|
53
32
|
def arrow_end_point
|
|
54
33
|
[
|
|
55
|
-
[
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
x+(2*ARROW_LENGTH)+length,
|
|
61
|
-
y+(ARROW_WIDTH/2)
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
x+ARROW_LENGTH+length,
|
|
65
|
-
y+ARROW_WIDTH
|
|
66
|
-
]
|
|
34
|
+
[ x+ARROW_LENGTH+length, y ],
|
|
35
|
+
[ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2) ],
|
|
36
|
+
[ x+ARROW_LENGTH+length, y+ARROW_WIDTH ]
|
|
67
37
|
]
|
|
68
38
|
end
|
|
69
39
|
|
|
70
40
|
def arrow_end_flat
|
|
71
41
|
[
|
|
72
|
-
[
|
|
73
|
-
|
|
74
|
-
y+(ARROW_WIDTH/2)-(LINE_WIDTH/2)
|
|
75
|
-
],
|
|
76
|
-
[
|
|
77
|
-
x+(2*ARROW_LENGTH)+length,
|
|
78
|
-
y+(ARROW_WIDTH/2)+(LINE_WIDTH/2)
|
|
79
|
-
]
|
|
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) ]
|
|
80
44
|
]
|
|
81
45
|
end
|
|
82
46
|
|
|
83
47
|
def arrow_end_side
|
|
84
48
|
[
|
|
85
|
-
[
|
|
86
|
-
|
|
87
|
-
y+(ARROW_WIDTH/2)+(LINE_WIDTH/2)
|
|
88
|
-
],
|
|
89
|
-
[
|
|
90
|
-
x+ARROW_LENGTH,
|
|
91
|
-
y+(ARROW_WIDTH/2)+(LINE_WIDTH/2)
|
|
92
|
-
]
|
|
49
|
+
[ x+ARROW_LENGTH+length, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ],
|
|
50
|
+
[ x+ARROW_LENGTH, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ]
|
|
93
51
|
]
|
|
94
52
|
end
|
|
95
53
|
|
|
@@ -9,87 +9,45 @@ module GridGenerator
|
|
|
9
9
|
|
|
10
10
|
def arrow_start_point
|
|
11
11
|
[
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
],
|
|
16
|
-
[
|
|
17
|
-
x+(ARROW_WIDTH/2),
|
|
18
|
-
y
|
|
19
|
-
],
|
|
20
|
-
[
|
|
21
|
-
x+ARROW_WIDTH,
|
|
22
|
-
y+ARROW_LENGTH
|
|
23
|
-
]
|
|
12
|
+
[ x, y+ARROW_LENGTH ],
|
|
13
|
+
[ x+(ARROW_WIDTH/2), y ],
|
|
14
|
+
[ x+ARROW_WIDTH, y+ARROW_LENGTH ]
|
|
24
15
|
]
|
|
25
16
|
end
|
|
26
17
|
|
|
27
18
|
def arrow_start_flat
|
|
28
19
|
[
|
|
29
|
-
[
|
|
30
|
-
|
|
31
|
-
y
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
x+(ARROW_WIDTH/2)+(LINE_WIDTH/2),
|
|
35
|
-
y
|
|
36
|
-
]
|
|
20
|
+
[ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y ],
|
|
21
|
+
[ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y ]
|
|
37
22
|
]
|
|
38
23
|
end
|
|
39
24
|
|
|
40
25
|
def arrow_start_side
|
|
41
26
|
[
|
|
42
|
-
[
|
|
43
|
-
|
|
44
|
-
y+ARROW_LENGTH
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
x+(ARROW_WIDTH/2)+(LINE_WIDTH/2),
|
|
48
|
-
y+ARROW_LENGTH+length
|
|
49
|
-
]
|
|
27
|
+
[ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y+ARROW_LENGTH ],
|
|
28
|
+
[ x+(ARROW_WIDTH/2)+(LINE_WIDTH/2), y+ARROW_LENGTH+length ]
|
|
50
29
|
]
|
|
51
30
|
end
|
|
52
31
|
|
|
53
32
|
def arrow_end_point
|
|
54
33
|
[
|
|
55
|
-
[
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
x+(ARROW_WIDTH/2),
|
|
61
|
-
y+(ARROW_LENGTH*2)+length
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
x,
|
|
65
|
-
y+ARROW_LENGTH+length
|
|
66
|
-
]
|
|
34
|
+
[ x+ARROW_WIDTH, y+ARROW_LENGTH+length ],
|
|
35
|
+
[ x+(ARROW_WIDTH/2), y+(ARROW_LENGTH*2)+length ],
|
|
36
|
+
[ x, y+ARROW_LENGTH+length ]
|
|
67
37
|
]
|
|
68
38
|
end
|
|
69
39
|
|
|
70
40
|
def arrow_end_flat
|
|
71
41
|
[
|
|
72
|
-
[
|
|
73
|
-
|
|
74
|
-
y+(2*ARROW_LENGTH)+length
|
|
75
|
-
],
|
|
76
|
-
[
|
|
77
|
-
x+(ARROW_WIDTH/2)-(LINE_WIDTH/2),
|
|
78
|
-
y+(2*ARROW_LENGTH)+length
|
|
79
|
-
]
|
|
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 ]
|
|
80
44
|
]
|
|
81
45
|
end
|
|
82
46
|
|
|
83
47
|
def arrow_end_side
|
|
84
48
|
[
|
|
85
|
-
[
|
|
86
|
-
|
|
87
|
-
y+ARROW_LENGTH+length
|
|
88
|
-
],
|
|
89
|
-
[
|
|
90
|
-
x+(ARROW_WIDTH/2)-(LINE_WIDTH/2),
|
|
91
|
-
y+ARROW_LENGTH
|
|
92
|
-
]
|
|
49
|
+
[ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y+ARROW_LENGTH+length ],
|
|
50
|
+
[ x+(ARROW_WIDTH/2)-(LINE_WIDTH/2), y+ARROW_LENGTH ]
|
|
93
51
|
]
|
|
94
52
|
end
|
|
95
53
|
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
require_relative 'grid'
|
|
2
|
+
require_relative 'units_factory'
|
|
2
3
|
|
|
3
4
|
module GridGenerator
|
|
4
5
|
module Cubic
|
|
5
6
|
class FrontGrid < GridGenerator::Cubic::Grid
|
|
6
|
-
def
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def height_unit
|
|
11
|
-
@height_unit ||= Matrix.column_vector([0, units])
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def offset_unit
|
|
15
|
-
@offset_unit ||= Matrix.column_vector([0,0])
|
|
7
|
+
def side
|
|
8
|
+
:front
|
|
16
9
|
end
|
|
17
10
|
|
|
18
11
|
def line_offset_amount
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'matrix'
|
|
2
|
-
require_relative '../face_parser'
|
|
3
2
|
require_relative '../base_line'
|
|
4
3
|
|
|
5
4
|
module GridGenerator
|
|
@@ -10,7 +9,7 @@ module GridGenerator
|
|
|
10
9
|
@units = units
|
|
11
10
|
@squares = case squares
|
|
12
11
|
when String
|
|
13
|
-
|
|
12
|
+
squares.split('\n').map { |r| r.split(',') }
|
|
14
13
|
when Array
|
|
15
14
|
squares
|
|
16
15
|
else
|
|
@@ -34,6 +33,19 @@ module GridGenerator
|
|
|
34
33
|
def height
|
|
35
34
|
@height ||= squares.size
|
|
36
35
|
end
|
|
36
|
+
|
|
37
|
+
# units
|
|
38
|
+
def width_unit
|
|
39
|
+
@width_unit ||= GridGenerator::Cubic::UnitsFactory.new(side: side, type: :width, units: units).build
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def height_unit
|
|
43
|
+
@height_unit ||= GridGenerator::Cubic::UnitsFactory.new(side: side, type: :height, units: units).build
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def offset_unit
|
|
47
|
+
@offset_unit ||= GridGenerator::Cubic::UnitsFactory.new(side: side, type: :offset, units: units).build
|
|
48
|
+
end
|
|
37
49
|
|
|
38
50
|
# positioning squares
|
|
39
51
|
|
|
@@ -108,12 +120,10 @@ module GridGenerator
|
|
|
108
120
|
GridGenerator::Cubic::SquareFactory.new(
|
|
109
121
|
x: square_position(row_num, col_num)[0,0],
|
|
110
122
|
y: square_position(row_num, col_num)[1,0],
|
|
111
|
-
units: units,
|
|
112
123
|
width_unit: width_unit,
|
|
113
124
|
height_unit: height_unit,
|
|
114
125
|
offset_unit: offset_unit,
|
|
115
|
-
|
|
116
|
-
opacity: col[:opacity]
|
|
126
|
+
face: col
|
|
117
127
|
).build
|
|
118
128
|
end
|
|
119
129
|
end
|
|
@@ -3,18 +3,10 @@ require_relative 'grid'
|
|
|
3
3
|
module GridGenerator
|
|
4
4
|
module Cubic
|
|
5
5
|
class RightGrid < Cubic::Grid
|
|
6
|
-
def
|
|
7
|
-
|
|
6
|
+
def side
|
|
7
|
+
:right
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
def height_unit
|
|
11
|
-
@height_unit ||= Matrix.column_vector([0, units])
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def offset_unit
|
|
15
|
-
@offset_unit ||= Matrix.column_vector([0,(units*0.5).to_i])
|
|
16
|
-
end
|
|
17
|
-
|
|
9
|
+
|
|
18
10
|
def line_offset_amount
|
|
19
11
|
width
|
|
20
12
|
end
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
require_relative '../base_element'
|
|
2
|
+
require_relative 'units_factory'
|
|
2
3
|
|
|
3
4
|
module GridGenerator
|
|
4
5
|
module Cubic
|
|
5
6
|
class SquareFactory
|
|
6
|
-
def initialize(x:, y:,
|
|
7
|
+
def initialize(x:, y:, width_unit:, height_unit:, offset_unit:, face:)
|
|
7
8
|
@x, @y = x, y
|
|
8
|
-
@
|
|
9
|
-
@
|
|
9
|
+
@width_unit = width_unit
|
|
10
|
+
@height_unit = height_unit
|
|
10
11
|
@offset_unit = offset_unit
|
|
11
|
-
|
|
12
|
+
face_attr = FaceParser.new(face).parse
|
|
13
|
+
@colour = face_attr && face_attr[:colour]
|
|
14
|
+
@opacity = face_attr && face_attr[:opacity]
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
attr_reader :x, :y, :
|
|
17
|
+
attr_reader :x, :y, :width_unit, :height_unit, :offset_unit, :colour, :opacity
|
|
15
18
|
|
|
16
19
|
def top_left
|
|
17
20
|
Matrix.column_vector([x, y]) + offset_unit
|
|
@@ -39,7 +42,7 @@ module GridGenerator
|
|
|
39
42
|
end
|
|
40
43
|
|
|
41
44
|
def build
|
|
42
|
-
GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity)
|
|
45
|
+
GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity) unless colour.nil?
|
|
43
46
|
end
|
|
44
47
|
end
|
|
45
48
|
end
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
require_relative 'grid'
|
|
2
|
+
require_relative 'units_factory'
|
|
2
3
|
|
|
3
4
|
module GridGenerator
|
|
4
5
|
module Cubic
|
|
5
6
|
class TopGrid < Cubic::Grid
|
|
6
|
-
def
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def height_unit
|
|
11
|
-
@height_unit ||= Matrix.column_vector([-units, units/2])
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def offset_unit
|
|
15
|
-
@offset_unit ||= Matrix.column_vector([units,0])
|
|
7
|
+
def side
|
|
8
|
+
:top
|
|
16
9
|
end
|
|
17
10
|
|
|
18
11
|
def line_offset_amount
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module GridGenerator
|
|
2
|
+
module Cubic
|
|
3
|
+
class UnitsFactory
|
|
4
|
+
def initialize(side:, type:, units:)
|
|
5
|
+
raise ArgumentError "Unknown Side" unless [:top, :front, :right].include?(side)
|
|
6
|
+
raise ArgumentError "Unknown Type" unless [:width, :height, :offset].include?(type)
|
|
7
|
+
@side = side
|
|
8
|
+
@type = type
|
|
9
|
+
@units = units
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :side, :type, :units
|
|
13
|
+
|
|
14
|
+
def top_unit
|
|
15
|
+
case type
|
|
16
|
+
when :width
|
|
17
|
+
Matrix.column_vector([units, units/2])
|
|
18
|
+
when :height
|
|
19
|
+
Matrix.column_vector([-units, units/2])
|
|
20
|
+
when :offset
|
|
21
|
+
Matrix.column_vector([units,0])
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def front_unit
|
|
26
|
+
case type
|
|
27
|
+
when :width
|
|
28
|
+
Matrix.column_vector([units, units/2])
|
|
29
|
+
when :height
|
|
30
|
+
Matrix.column_vector([0, units])
|
|
31
|
+
when :offset
|
|
32
|
+
Matrix.column_vector([0,0])
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def right_unit
|
|
37
|
+
case type
|
|
38
|
+
when :width
|
|
39
|
+
Matrix.column_vector([units, (units*-0.5).to_i])
|
|
40
|
+
when :height
|
|
41
|
+
Matrix.column_vector([0, units])
|
|
42
|
+
when :offset
|
|
43
|
+
Matrix.column_vector([0,(units*0.5).to_i])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def build
|
|
48
|
+
case side
|
|
49
|
+
when :top
|
|
50
|
+
top_unit
|
|
51
|
+
when :front
|
|
52
|
+
front_unit
|
|
53
|
+
when :right
|
|
54
|
+
right_unit
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
@@ -12,7 +12,10 @@ module GridGenerator
|
|
|
12
12
|
's' => '#8080ff',
|
|
13
13
|
'l' => '#80ff80',
|
|
14
14
|
'p' => '#800080',
|
|
15
|
-
'pi' => '#ff8080'
|
|
15
|
+
'pi' => '#ff8080',
|
|
16
|
+
'fu' => "#f0f0f0", # face up
|
|
17
|
+
'ff' => "#d0d0d0", # face front
|
|
18
|
+
'fr' => "#b0b0b0" # face right
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
OPACITY = {
|
|
@@ -23,19 +26,35 @@ module GridGenerator
|
|
|
23
26
|
def initialize(string)
|
|
24
27
|
@string = string
|
|
25
28
|
end
|
|
29
|
+
|
|
30
|
+
def single?
|
|
31
|
+
@string.length == 1
|
|
32
|
+
end
|
|
26
33
|
|
|
27
34
|
attr_reader :string
|
|
35
|
+
|
|
36
|
+
def parse
|
|
37
|
+
if single?
|
|
38
|
+
parse_char(string)
|
|
39
|
+
else
|
|
40
|
+
parse_array(string)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
28
43
|
|
|
29
|
-
def
|
|
30
|
-
|
|
44
|
+
def parse_char(char)
|
|
45
|
+
if char == '-'
|
|
46
|
+
nil
|
|
47
|
+
else
|
|
48
|
+
colour = COLOURS[char.downcase]
|
|
49
|
+
opacity = OPACITY[(/[[:upper:]]/.match(char) ? :full : :faded)]
|
|
50
|
+
{ colour: colour, opacity: opacity }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def parse_array(str)
|
|
55
|
+
str.split(/\\n/).map do |line|
|
|
31
56
|
line.split(',').map(&:strip).map do |col|
|
|
32
|
-
|
|
33
|
-
nil
|
|
34
|
-
else
|
|
35
|
-
colour = COLOURS[col.downcase]
|
|
36
|
-
opacity = OPACITY[(/[[:upper:]]/.match(col) ? :full : :faded)]
|
|
37
|
-
{ colour: colour, opacity: opacity }
|
|
38
|
-
end
|
|
57
|
+
parse_char(col)
|
|
39
58
|
end
|
|
40
59
|
end
|
|
41
60
|
end
|
|
@@ -10,7 +10,7 @@ module GridGenerator
|
|
|
10
10
|
def initialize(x:, y: , units: , elements: , rotation_offset: 0, label: nil)
|
|
11
11
|
@x, @y = x, y
|
|
12
12
|
@units = units
|
|
13
|
-
@elements = FaceParser.new(elements).
|
|
13
|
+
@elements = FaceParser.new(elements).parse
|
|
14
14
|
@rotation_offset = rotation_offset
|
|
15
15
|
@label = label
|
|
16
16
|
end
|
data/lib/grid_generator.rb
CHANGED
|
@@ -25,18 +25,6 @@ module GridGenerator
|
|
|
25
25
|
Cubic::IsoView.new(**args)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def self.top_grid(args)
|
|
29
|
-
Cubic::TopGrid.new(**args)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def self.front_grid(args)
|
|
33
|
-
Cubic::FrontGrid.new(**args)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def self.right_grid(args)
|
|
37
|
-
Cubic::RightGrid.new(**args)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
28
|
def self.facing_grid(args)
|
|
41
29
|
Cubic::FacingGrid.new(**args)
|
|
42
30
|
end
|
|
@@ -45,19 +33,19 @@ module GridGenerator
|
|
|
45
33
|
Cubic::BorderedGrid.new(**args)
|
|
46
34
|
end
|
|
47
35
|
|
|
48
|
-
def self.
|
|
49
|
-
|
|
50
|
-
Cubic::
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
def self.square(args)
|
|
37
|
+
width_unit = GridGenerator::Cubic::UnitsFactory.new(side: args[:side], type: :width, units: args[:units]).build
|
|
38
|
+
height_unit = GridGenerator::Cubic::UnitsFactory.new(side: args[:side], type: :height, units: args[:units]).build
|
|
39
|
+
offset_unit = GridGenerator::Cubic::UnitsFactory.new(side: args[:side], type: :offset, units: args[:units]).build
|
|
40
|
+
|
|
41
|
+
GridGenerator::Cubic::SquareFactory.new(
|
|
42
|
+
x: args[:x],
|
|
43
|
+
y: args[:y],
|
|
44
|
+
width_unit: width_unit,
|
|
45
|
+
height_unit: height_unit,
|
|
46
|
+
offset_unit: offset_unit,
|
|
47
|
+
face: args[:face]
|
|
48
|
+
).build
|
|
61
49
|
end
|
|
62
50
|
|
|
63
51
|
def self.top_skewb_grid(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.
|
|
4
|
+
version: 0.1.5
|
|
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-
|
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: matrix
|
|
@@ -56,6 +56,7 @@ files:
|
|
|
56
56
|
- lib/grid_generator/cubic/right_grid.rb
|
|
57
57
|
- lib/grid_generator/cubic/square_factory.rb
|
|
58
58
|
- lib/grid_generator/cubic/top_grid.rb
|
|
59
|
+
- lib/grid_generator/cubic/units_factory.rb
|
|
59
60
|
- lib/grid_generator/face_parser.rb
|
|
60
61
|
- lib/grid_generator/megaminx/common.rb
|
|
61
62
|
- lib/grid_generator/megaminx/element_factory.rb
|