grid_generator 0.1.4 → 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/cubic/bordered_grid.rb +1 -1
- data/lib/grid_generator/cubic/facing_grid.rb +1 -1
- data/lib/grid_generator/cubic/grid.rb +2 -4
- data/lib/grid_generator/cubic/square_factory.rb +5 -3
- 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 +1 -2
- metadata +2 -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
@@ -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
|
@@ -124,8 +123,7 @@ module GridGenerator
|
|
124
123
|
width_unit: width_unit,
|
125
124
|
height_unit: height_unit,
|
126
125
|
offset_unit: offset_unit,
|
127
|
-
|
128
|
-
opacity: col[:opacity]
|
126
|
+
face: col
|
129
127
|
).build
|
130
128
|
end
|
131
129
|
end
|
@@ -4,12 +4,14 @@ require_relative 'units_factory'
|
|
4
4
|
module GridGenerator
|
5
5
|
module Cubic
|
6
6
|
class SquareFactory
|
7
|
-
def initialize(x:, y:, width_unit:, height_unit:, offset_unit:,
|
7
|
+
def initialize(x:, y:, width_unit:, height_unit:, offset_unit:, face:)
|
8
8
|
@x, @y = x, y
|
9
9
|
@width_unit = width_unit
|
10
10
|
@height_unit = height_unit
|
11
11
|
@offset_unit = offset_unit
|
12
|
-
|
12
|
+
face_attr = FaceParser.new(face).parse
|
13
|
+
@colour = face_attr && face_attr[:colour]
|
14
|
+
@opacity = face_attr && face_attr[:opacity]
|
13
15
|
end
|
14
16
|
|
15
17
|
attr_reader :x, :y, :width_unit, :height_unit, :offset_unit, :colour, :opacity
|
@@ -40,7 +42,7 @@ module GridGenerator
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def build
|
43
|
-
GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity)
|
45
|
+
GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity) unless colour.nil?
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -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
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
|