grid_generator 0.1.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c37d1d10aae708a8406359d0082de82ab9426d760bc34ddfd34f916e55b86776
4
- data.tar.gz: 227df89f4324e8418afef7eb1705d3a19205095d3be359bf6ee9d7f7981a8f37
3
+ metadata.gz: e6f97c8ba195b68150195c0f9c90ca93dccc6c56bb5b466336b2065b7473c9ac
4
+ data.tar.gz: df39197455ecf27cd3d0076ea823c896bc3b0921e0df7465a0ea9cabe35e3d06
5
5
  SHA512:
6
- metadata.gz: 1280447a17b87c59ec84b81105f20607167f535b0660c43b39ec2d7db719fc92a8027a2f52efd04e6d5afae1660f4755c6cc1e3cc7a5543ea5eb6a9700534cc7
7
- data.tar.gz: efcfe14dcfce8a2ef7927a00f032a7c4bd64d631ec5981da629a344093282a2a2e8bec2aac402b298abdb94926142433c1846ff5b4eed66b2640f8133bc8e122
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.1)
4
+ grid_generator (0.1.2)
5
5
  matrix (~> 0.4.2)
6
6
 
7
7
  GEM
@@ -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,4 +1,5 @@
1
1
  require_relative '../face_parser'
2
+ require_relative '../base_element'
2
3
  require_relative 'facing_square_factory'
3
4
 
4
5
  module GridGenerator
@@ -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,4 +1,5 @@
1
1
  require_relative '../face_parser'
2
+ require_relative '../base_line'
2
3
  require_relative 'facing_square_factory'
3
4
 
4
5
  module GridGenerator
@@ -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,5 +1,6 @@
1
1
  require 'matrix'
2
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,4 @@
1
+ require_relative '../base_line'
1
2
  require_relative 'triangle_factory'
2
3
 
3
4
  module GridGenerator
@@ -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,3 +1,4 @@
1
+ require_relative '../base_line'
1
2
  require_relative 'skewb_grid'
2
3
  require_relative 'left_element_factory'
3
4
 
@@ -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,4 @@
1
+ require_relative '../base_element'
1
2
  require_relative 'skewb_grid.rb'
2
3
  require_relative 'right_element_factory.rb'
3
4
 
@@ -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,3 +1,4 @@
1
+ require_relative '../base_element'
1
2
  require_relative 'skewb_grid'
2
3
  require_relative 'top_element_factory'
3
4
 
@@ -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,3 +1,4 @@
1
+ require_relative '../base_line'
1
2
  require_relative '../square_one_face_parser'
2
3
  require_relative 'element_factory'
3
4
 
@@ -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.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grid_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Humphreys
@@ -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