grid_generator 0.3.3 → 0.4.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/curvy_copter/element_factory.rb +144 -0
- data/lib/grid_generator/curvy_copter/grid.rb +56 -0
- data/lib/grid_generator/curvy_copter/left_element_factory.rb +37 -0
- data/lib/grid_generator/curvy_copter/left_grid.rb +13 -0
- data/lib/grid_generator/curvy_copter/right_element_factory.rb +37 -0
- data/lib/grid_generator/curvy_copter/right_grid.rb +13 -0
- data/lib/grid_generator/curvy_copter/top_element_factory.rb +37 -0
- data/lib/grid_generator/curvy_copter/top_grid.rb +13 -0
- data/lib/grid_generator/svg/close_command.rb +20 -0
- data/lib/grid_generator/svg/line_command.rb +12 -0
- data/lib/grid_generator/svg/move_command.rb +12 -0
- data/lib/grid_generator/svg/path.rb +30 -0
- data/lib/grid_generator/svg/path_command.rb +38 -0
- data/lib/grid_generator/svg/polygon.rb +11 -2
- data/lib/grid_generator/svg/quadratic_command.rb +12 -0
- data/lib/grid_generator/svg/style.rb +1 -1
- data/lib/grid_generator/version.rb +1 -1
- data/lib/grid_generator.rb +15 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ac9ef7317cd0dac36826db72f9bec140e103819ccf1a73bb716c77717f934c6
|
4
|
+
data.tar.gz: 4cd030cf4ae775dfd56f3f4067a7deaaf796a1a3b658264565a80f760314af65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ac448265f10cb14b73effbcb0da1faadec2bd070fd0e99f27f2a841151f0a3681b25875bca86b34de03c5f41e1f9c48e64f71014d2fe46472336997277b97bb
|
7
|
+
data.tar.gz: e3cb334d24401f39a9c52c795f31f3831c04d16d31aa4e77f1d16aa63e02bd13255895eceaf219b7430cefadcd934fc0515c6e0d0bea7bebb73259a03b9743b9
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'matrix'
|
2
|
+
require_relative '../svg/style'
|
3
|
+
require_relative '../svg/path'
|
4
|
+
require_relative '../svg/move_command'
|
5
|
+
require_relative '../svg/line_command'
|
6
|
+
require_relative '../svg/quadratic_command'
|
7
|
+
require_relative '../svg/close_command'
|
8
|
+
|
9
|
+
module GridGenerator
|
10
|
+
module CurvyCopter
|
11
|
+
class ElementFactory
|
12
|
+
def initialize(grid_x:, grid_y:, row_num:, col_num:, units:, colour:, opacity:)
|
13
|
+
@grid_x, @grid_y = grid_x, grid_y
|
14
|
+
@row_num, @col_num = row_num, col_num
|
15
|
+
@units = units
|
16
|
+
@colour, @opacity = colour, opacity
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :grid_x, :grid_y, :row_num, :col_num, :units, :colour, :opacity
|
20
|
+
|
21
|
+
def offset
|
22
|
+
@offset ||= Matrix.column_vector([grid_x, grid_y])
|
23
|
+
end
|
24
|
+
|
25
|
+
def anchors
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
|
29
|
+
def commands
|
30
|
+
case [row_num, col_num]
|
31
|
+
when [0, 0] # Top Left Corner
|
32
|
+
[
|
33
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:top_left_corner]]),
|
34
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:top_edge_left]]),
|
35
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_left_corner_center], anchors[:left_edge_top]]),
|
36
|
+
GridGenerator::Svg::CloseCommand.new
|
37
|
+
]
|
38
|
+
when [0, 1] # Top Middle Edge
|
39
|
+
[
|
40
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:top_edge_left]]),
|
41
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:top_edge_right]]),
|
42
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_edge_center], anchors[:center]]),
|
43
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_edge_center], anchors[:top_edge_left]]),
|
44
|
+
GridGenerator::Svg::CloseCommand.new
|
45
|
+
]
|
46
|
+
when [0, 2] # Top Right Corner
|
47
|
+
[
|
48
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:top_edge_right]]),
|
49
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:top_right_corner]]),
|
50
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:right_edge_top]]),
|
51
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_right_corner_center], anchors[:top_edge_right]]),
|
52
|
+
GridGenerator::Svg::CloseCommand.new
|
53
|
+
]
|
54
|
+
when [1, 0] # Top Left Middle
|
55
|
+
[
|
56
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:top_edge_left]]),
|
57
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_edge_center], anchors[:center]]),
|
58
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:left_edge_center], anchors[:left_edge_top]]),
|
59
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_left_corner_center], anchors[:top_edge_left]]),
|
60
|
+
GridGenerator::Svg::CloseCommand.new
|
61
|
+
]
|
62
|
+
when [1, 1] # Top Right Middle
|
63
|
+
[
|
64
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:top_edge_right]]),
|
65
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_right_corner_center], anchors[:right_edge_top]]),
|
66
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:right_edge_center], anchors[:center]]),
|
67
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:top_edge_center], anchors[:top_edge_right]]),
|
68
|
+
GridGenerator::Svg::CloseCommand.new
|
69
|
+
]
|
70
|
+
when [2, 0] # Middle Left Edge
|
71
|
+
[
|
72
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:left_edge_top]]),
|
73
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:left_edge_center], anchors[:center]]),
|
74
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:left_edge_center], anchors[:left_edge_bottom]]),
|
75
|
+
GridGenerator::Svg::CloseCommand.new
|
76
|
+
]
|
77
|
+
when [2, 1] # Middle Right Edge
|
78
|
+
[
|
79
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:right_edge_top]]),
|
80
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:right_edge_bottom]]),
|
81
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:right_edge_center], anchors[:center]]),
|
82
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:right_edge_center], anchors[:right_edge_top]]),
|
83
|
+
GridGenerator::Svg::CloseCommand.new
|
84
|
+
]
|
85
|
+
when [3, 0] # Bottom Left Middle
|
86
|
+
[
|
87
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:left_edge_bottom]]),
|
88
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:left_edge_center], anchors[:center]]),
|
89
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_edge_center], anchors[:bottom_edge_left]]),
|
90
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_left_corner_center], anchors[:left_edge_bottom]]),
|
91
|
+
GridGenerator::Svg::CloseCommand.new
|
92
|
+
]
|
93
|
+
when [3, 1] # Bottom Right Middle
|
94
|
+
[
|
95
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:center]]),
|
96
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:right_edge_center], anchors[:right_edge_bottom]]),
|
97
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_right_corner_center], anchors[:bottom_edge_right]]),
|
98
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_edge_center], anchors[:center]]),
|
99
|
+
GridGenerator::Svg::CloseCommand.new
|
100
|
+
]
|
101
|
+
when [4, 0] # Bottom Left Corner
|
102
|
+
[
|
103
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:left_edge_bottom]]),
|
104
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_left_corner_center], anchors[:bottom_edge_left]]),
|
105
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:bottom_left_corner]]),
|
106
|
+
GridGenerator::Svg::CloseCommand.new
|
107
|
+
]
|
108
|
+
when [4, 1] # Bottom Middle Edge
|
109
|
+
[
|
110
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:center]]),
|
111
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_edge_center], anchors[:bottom_edge_right]]),
|
112
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:bottom_edge_left]]),
|
113
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_edge_center], anchors[:center]]),
|
114
|
+
GridGenerator::Svg::CloseCommand.new
|
115
|
+
]
|
116
|
+
when [4, 2] # Bottom Right Corner
|
117
|
+
[
|
118
|
+
GridGenerator::Svg::MoveCommand.new(points: [anchors[:right_edge_bottom]]),
|
119
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:bottom_right_corner]]),
|
120
|
+
GridGenerator::Svg::LineCommand.new(points: [anchors[:bottom_edge_right]]),
|
121
|
+
GridGenerator::Svg::QuadraticCommand.new(points: [anchors[:bottom_right_corner_center], anchors[:right_edge_bottom]]),
|
122
|
+
GridGenerator::Svg::CloseCommand.new
|
123
|
+
]
|
124
|
+
else
|
125
|
+
[]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def style
|
130
|
+
GridGenerator::Svg::Style.new(fill: colour, opacity: opacity)
|
131
|
+
end
|
132
|
+
|
133
|
+
def d
|
134
|
+
commands.map do |c|
|
135
|
+
(c + offset)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def build
|
140
|
+
GridGenerator::Svg::Path.new(d: d, style: style)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../face_parser'
|
2
|
+
|
3
|
+
module GridGenerator
|
4
|
+
module CurvyCopter
|
5
|
+
class Grid
|
6
|
+
def initialize(x:, y:, units: , elements: )
|
7
|
+
@x, @y = x, y
|
8
|
+
@units = units
|
9
|
+
@elements = case elements
|
10
|
+
when String
|
11
|
+
FaceParser.new(elements).parse
|
12
|
+
when Array
|
13
|
+
elements
|
14
|
+
else
|
15
|
+
raise ArgumentError, "elements must be array or string"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :x, :y, :units, :elements
|
20
|
+
|
21
|
+
def to_svg
|
22
|
+
output = ''
|
23
|
+
|
24
|
+
element_shapes.each { |element| output += element.to_svg if element }
|
25
|
+
|
26
|
+
output
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def build_element(row_num, col_num, data)
|
32
|
+
if data
|
33
|
+
element_factory_class.new(
|
34
|
+
grid_x: x,
|
35
|
+
grid_y: y,
|
36
|
+
row_num: row_num,
|
37
|
+
col_num: col_num,
|
38
|
+
units: units,
|
39
|
+
colour: data[:colour],
|
40
|
+
opacity: data[:opacity]
|
41
|
+
).build
|
42
|
+
else
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def element_shapes
|
48
|
+
elements.each_with_index.map do |row, row_num|
|
49
|
+
row.each_with_index.map do |col, col_num|
|
50
|
+
build_element(row_num, col_num, col)
|
51
|
+
end
|
52
|
+
end.flatten.compact
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative './element_factory'
|
2
|
+
|
3
|
+
module GridGenerator
|
4
|
+
module CurvyCopter
|
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([3*units, 1.5*units]),
|
10
|
+
bottom_left_corner: Matrix.column_vector([0, 3*units]),
|
11
|
+
bottom_right_corner: Matrix.column_vector([3*units, 4.5*units]),
|
12
|
+
|
13
|
+
top_edge_left: Matrix.column_vector([units, 0.5*units]),
|
14
|
+
top_edge_right: Matrix.column_vector([2*units, units]),
|
15
|
+
right_edge_top: Matrix.column_vector([3*units, 2.5*units]),
|
16
|
+
right_edge_bottom: Matrix.column_vector([3*units, 3.5*units]),
|
17
|
+
bottom_edge_left: Matrix.column_vector([units, 3.5*units]),
|
18
|
+
bottom_edge_right: Matrix.column_vector([2*units, 4*units]),
|
19
|
+
left_edge_top: Matrix.column_vector([0, units]),
|
20
|
+
left_edge_bottom: Matrix.column_vector([0, 2*units]),
|
21
|
+
|
22
|
+
center: Matrix.column_vector([1.5*units, 2.25*units]),
|
23
|
+
|
24
|
+
top_edge_center: Matrix.column_vector([1.5*units, 1.5*units]),
|
25
|
+
right_edge_center: Matrix.column_vector([2.25*units, 2.625*units ]),
|
26
|
+
bottom_edge_center: Matrix.column_vector([1.5*units, 3*units ]),
|
27
|
+
left_edge_center: Matrix.column_vector([0.75*units, 1.875*units]),
|
28
|
+
|
29
|
+
top_left_corner_center: Matrix.column_vector([0.75*units, 1.125*units]),
|
30
|
+
top_right_corner_center: Matrix.column_vector([2.25*units, 1.875*units]),
|
31
|
+
bottom_left_corner_center: Matrix.column_vector([0.75*units, 2.625*units ]),
|
32
|
+
bottom_right_corner_center: Matrix.column_vector([2.25*units,3.375*units])
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative './element_factory'
|
2
|
+
|
3
|
+
module GridGenerator
|
4
|
+
module CurvyCopter
|
5
|
+
class RightElementFactory < ElementFactory
|
6
|
+
def anchors
|
7
|
+
@anchors ||= {
|
8
|
+
top_left_corner: Matrix.column_vector([0, 1.5*units]),
|
9
|
+
top_right_corner: Matrix.column_vector([3*units, 0*units]),
|
10
|
+
bottom_left_corner: Matrix.column_vector([0, 4.5*units]),
|
11
|
+
bottom_right_corner: Matrix.column_vector([3*units, 3*units]),
|
12
|
+
|
13
|
+
top_edge_left: Matrix.column_vector([units, units]),
|
14
|
+
top_edge_right: Matrix.column_vector([2*units, 0.5*units]),
|
15
|
+
right_edge_top: Matrix.column_vector([3*units, units]),
|
16
|
+
right_edge_bottom: Matrix.column_vector([3*units, 2*units]),
|
17
|
+
bottom_edge_left: Matrix.column_vector([units, 4*units]),
|
18
|
+
bottom_edge_right: Matrix.column_vector([2*units, 3.5*units]),
|
19
|
+
left_edge_top: Matrix.column_vector([0, 2.5*units]),
|
20
|
+
left_edge_bottom: Matrix.column_vector([0, 3.5*units]),
|
21
|
+
|
22
|
+
center: Matrix.column_vector([1.5*units, 2.25*units]),
|
23
|
+
|
24
|
+
top_edge_center: Matrix.column_vector([1.5*units, 1.5*units]),
|
25
|
+
right_edge_center: Matrix.column_vector([2.25*units, 1.875*units ]),
|
26
|
+
bottom_edge_center: Matrix.column_vector([1.5*units, 3*units ]),
|
27
|
+
left_edge_center: Matrix.column_vector([0.75*units, 2.625*units]),
|
28
|
+
|
29
|
+
top_left_corner_center: Matrix.column_vector([0.75*units, 1.875*units]),
|
30
|
+
top_right_corner_center: Matrix.column_vector([2.25*units, 1.125*units]),
|
31
|
+
bottom_left_corner_center: Matrix.column_vector([0.75*units, 3.375*units ]),
|
32
|
+
bottom_right_corner_center: Matrix.column_vector([2.25*units, 2.625*units])
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../face_parser'
|
2
|
+
require_relative './grid'
|
3
|
+
require_relative './right_element_factory'
|
4
|
+
|
5
|
+
module GridGenerator
|
6
|
+
module CurvyCopter
|
7
|
+
class RightGrid < Grid
|
8
|
+
def element_factory_class
|
9
|
+
RightElementFactory
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative './element_factory'
|
2
|
+
|
3
|
+
module GridGenerator
|
4
|
+
module CurvyCopter
|
5
|
+
class TopElementFactory < ElementFactory
|
6
|
+
def anchors
|
7
|
+
@anchors ||= {
|
8
|
+
top_left_corner: Matrix.column_vector([3*units, 0]),
|
9
|
+
top_right_corner: Matrix.column_vector([6*units, 1.5*units]),
|
10
|
+
bottom_left_corner: Matrix.column_vector([0, 1.5*units]),
|
11
|
+
bottom_right_corner: Matrix.column_vector([3*units, 3*units]),
|
12
|
+
|
13
|
+
top_edge_left: Matrix.column_vector([4*units, 0.5*units]),
|
14
|
+
top_edge_right: Matrix.column_vector([5*units, units]),
|
15
|
+
right_edge_top: Matrix.column_vector([5*units, 2*units]),
|
16
|
+
right_edge_bottom: Matrix.column_vector([4*units, 2.5*units]),
|
17
|
+
bottom_edge_left: Matrix.column_vector([units, 2*units]),
|
18
|
+
bottom_edge_right: Matrix.column_vector([2*units, 2.5*units]),
|
19
|
+
left_edge_top: Matrix.column_vector([2*units, 0.5*units]),
|
20
|
+
left_edge_bottom: Matrix.column_vector([units, units]),
|
21
|
+
|
22
|
+
center: Matrix.column_vector([3*units, 1.5*units]),
|
23
|
+
|
24
|
+
top_edge_center: Matrix.column_vector([3.75*units, 1.125*units]),
|
25
|
+
right_edge_center: Matrix.column_vector([3.75*units, 1.875*units]),
|
26
|
+
bottom_edge_center: Matrix.column_vector([2.25*units, 1.875*units]),
|
27
|
+
left_edge_center: Matrix.column_vector([2.25*units, 1.125*units]),
|
28
|
+
|
29
|
+
top_left_corner_center: Matrix.column_vector([3*units, 0.75*units]),
|
30
|
+
top_right_corner_center: Matrix.column_vector([4.5*units, 1.5*units]),
|
31
|
+
bottom_left_corner_center: Matrix.column_vector([1.5*units, 1.5*units]),
|
32
|
+
bottom_right_corner_center: Matrix.column_vector([3*units, 2.25*units])
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module GridGenerator
|
2
|
+
module Svg
|
3
|
+
class Path
|
4
|
+
def initialize(d: , style:)
|
5
|
+
@d = case d
|
6
|
+
when String
|
7
|
+
d
|
8
|
+
when Array
|
9
|
+
d.map(&:to_s).join(' ')
|
10
|
+
else
|
11
|
+
raise ArgumentError, "d must be String or Array"
|
12
|
+
end
|
13
|
+
@style = case style
|
14
|
+
when GridGenerator::Svg::Style
|
15
|
+
style.to_s
|
16
|
+
when String
|
17
|
+
style
|
18
|
+
else
|
19
|
+
raise ArgumentError, "style must be String or Style"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :d, :style
|
24
|
+
|
25
|
+
def to_svg
|
26
|
+
"<path d=\"#{d}\" style=\"#{style}\" />"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module GridGenerator
|
2
|
+
module Svg
|
3
|
+
class PathCommand
|
4
|
+
def initialize(points: [])
|
5
|
+
@points = points
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :points
|
9
|
+
|
10
|
+
def type
|
11
|
+
'M'
|
12
|
+
end
|
13
|
+
|
14
|
+
def +(offset)
|
15
|
+
if offset.class == Matrix
|
16
|
+
new_points = points.map { |p| p + offset }
|
17
|
+
self.class.new(points: new_points)
|
18
|
+
else
|
19
|
+
raise ArgumentError, "Offset must be Matrix"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
self.class == other.class && self.points == other.points
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
[type, points_string].join(' ')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def points_string
|
34
|
+
points.map { |p| "#{p[0,0].round} #{p[1,0].round}" }.join(' ')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -5,10 +5,19 @@ module GridGenerator
|
|
5
5
|
@points = case points
|
6
6
|
when Array
|
7
7
|
points.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
|
8
|
-
|
8
|
+
when String
|
9
9
|
points
|
10
|
+
else
|
11
|
+
raise ArgumentError, "points must be Array or String"
|
10
12
|
end
|
11
|
-
@style = style
|
13
|
+
@style = case style
|
14
|
+
when GridGenerator::Svg::Style
|
15
|
+
style.to_s
|
16
|
+
when String
|
17
|
+
style
|
18
|
+
else
|
19
|
+
raise ArgumentError, "style must be String or Style"
|
20
|
+
end
|
12
21
|
end
|
13
22
|
|
14
23
|
attr_reader :points, :style
|
data/lib/grid_generator.rb
CHANGED
@@ -12,6 +12,9 @@ require_relative 'grid_generator/cubic/square_factory'
|
|
12
12
|
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
|
+
require_relative 'grid_generator/curvy_copter/top_grid'
|
16
|
+
require_relative 'grid_generator/curvy_copter/left_grid'
|
17
|
+
require_relative 'grid_generator/curvy_copter/right_grid'
|
15
18
|
require_relative 'grid_generator/square_one/face'
|
16
19
|
require_relative 'grid_generator/pyraminx/face'
|
17
20
|
require_relative 'grid_generator/megaminx/face_projection'
|
@@ -56,6 +59,18 @@ module GridGenerator
|
|
56
59
|
Skewb::RightSkewbGrid.new(**args)
|
57
60
|
end
|
58
61
|
|
62
|
+
def self.curvy_copter_top_grid(args)
|
63
|
+
CurvyCopter::TopGrid.new(**args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.curvy_copter_left_grid(args)
|
67
|
+
CurvyCopter::LeftGrid.new(**args)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.curvy_copter_right_grid(args)
|
71
|
+
CurvyCopter::RightGrid.new(**args)
|
72
|
+
end
|
73
|
+
|
59
74
|
def self.square_one_face(args)
|
60
75
|
SquareOne::Face.new(**args)
|
61
76
|
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.4.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-
|
11
|
+
date: 2023-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matrix
|
@@ -52,6 +52,14 @@ files:
|
|
52
52
|
- lib/grid_generator/cubic/square_factory.rb
|
53
53
|
- lib/grid_generator/cubic/top_grid.rb
|
54
54
|
- lib/grid_generator/cubic/units_factory.rb
|
55
|
+
- lib/grid_generator/curvy_copter/element_factory.rb
|
56
|
+
- lib/grid_generator/curvy_copter/grid.rb
|
57
|
+
- lib/grid_generator/curvy_copter/left_element_factory.rb
|
58
|
+
- lib/grid_generator/curvy_copter/left_grid.rb
|
59
|
+
- lib/grid_generator/curvy_copter/right_element_factory.rb
|
60
|
+
- lib/grid_generator/curvy_copter/right_grid.rb
|
61
|
+
- lib/grid_generator/curvy_copter/top_element_factory.rb
|
62
|
+
- lib/grid_generator/curvy_copter/top_grid.rb
|
55
63
|
- lib/grid_generator/face_parser.rb
|
56
64
|
- lib/grid_generator/helper.rb
|
57
65
|
- lib/grid_generator/megaminx/face_element_factory.rb
|
@@ -70,7 +78,13 @@ files:
|
|
70
78
|
- lib/grid_generator/square_one/element_factory.rb
|
71
79
|
- lib/grid_generator/square_one/face.rb
|
72
80
|
- lib/grid_generator/square_one_face_parser.rb
|
81
|
+
- lib/grid_generator/svg/close_command.rb
|
82
|
+
- lib/grid_generator/svg/line_command.rb
|
83
|
+
- lib/grid_generator/svg/move_command.rb
|
84
|
+
- lib/grid_generator/svg/path.rb
|
85
|
+
- lib/grid_generator/svg/path_command.rb
|
73
86
|
- lib/grid_generator/svg/polygon.rb
|
87
|
+
- lib/grid_generator/svg/quadratic_command.rb
|
74
88
|
- lib/grid_generator/svg/style.rb
|
75
89
|
- lib/grid_generator/version.rb
|
76
90
|
- sig/grid_generator.rbs
|