grid_generator 0.1.0 → 0.1.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/README.md +20 -10
- data/lib/grid_generator/arrows/diagonal_down_arrow.rb +1 -1
- data/lib/grid_generator/arrows/diagonal_up_arrow.rb +1 -1
- data/lib/grid_generator/arrows/horizontal_arrow.rb +1 -1
- data/lib/grid_generator/arrows/vertical_arrow.rb +1 -1
- data/lib/grid_generator/cubic/bordered_grid.rb +2 -2
- data/lib/grid_generator/cubic/facing_grid.rb +2 -2
- data/lib/grid_generator/cubic/facing_square_factory.rb +1 -1
- data/lib/grid_generator/cubic/front_grid.rb +1 -1
- data/lib/grid_generator/cubic/grid.rb +1 -1
- data/lib/grid_generator/cubic/iso_view.rb +4 -0
- data/lib/grid_generator/cubic/right_grid.rb +1 -1
- data/lib/grid_generator/cubic/square_factory.rb +1 -1
- data/lib/grid_generator/cubic/top_grid.rb +1 -1
- data/lib/grid_generator/megaminx/common.rb +1 -0
- data/lib/grid_generator/megaminx/element_factory.rb +2 -2
- data/lib/grid_generator/megaminx/face.rb +3 -3
- data/lib/grid_generator/pyraminx/grid.rb +1 -1
- data/lib/grid_generator/pyraminx/triangle_factory.rb +1 -1
- data/lib/grid_generator/skewb/left_element_factory.rb +2 -0
- data/lib/grid_generator/skewb/left_skewb_grid.rb +2 -2
- data/lib/grid_generator/skewb/right_element_factory.rb +2 -0
- data/lib/grid_generator/skewb/right_skewb_grid.rb +2 -2
- data/lib/grid_generator/skewb/skewb_grid.rb +1 -1
- data/lib/grid_generator/skewb/top_element_factory.rb +2 -0
- data/lib/grid_generator/skewb/top_skewb_grid.rb +2 -2
- data/lib/grid_generator/square_one/element_factory.rb +1 -1
- data/lib/grid_generator/square_one/face.rb +2 -2
- data/lib/grid_generator/version.rb +1 -1
- data/lib/grid_generator.rb +17 -17
- metadata +2 -3
- data/lib/grid_generator/square_one/element.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c37d1d10aae708a8406359d0082de82ab9426d760bc34ddfd34f916e55b86776
|
4
|
+
data.tar.gz: 227df89f4324e8418afef7eb1705d3a19205095d3be359bf6ee9d7f7981a8f37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1280447a17b87c59ec84b81105f20607167f535b0660c43b39ec2d7db719fc92a8027a2f52efd04e6d5afae1660f4755c6cc1e3cc7a5543ea5eb6a9700534cc7
|
7
|
+
data.tar.gz: efcfe14dcfce8a2ef7927a00f032a7c4bd64d631ec5981da629a344093282a2a2e8bec2aac402b298abdb94926142433c1846ff5b4eed66b2640f8133bc8e122
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
# GridGenerator
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/grid_generator`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
Library for generating grids based on twisty puzzles. The output can be used in svg `polygon` and `line` elements.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
7
|
Install the gem and add to the application's Gemfile by executing:
|
12
8
|
|
13
|
-
$ bundle add
|
9
|
+
$ bundle add grid_generator
|
14
10
|
|
15
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
12
|
|
17
|
-
$ gem install
|
13
|
+
$ gem install grid_generator
|
18
14
|
|
19
15
|
## Usage
|
20
16
|
|
21
|
-
|
17
|
+
Generate an iso grid at co-ordinates 20, 20, with each unit being 20.
|
18
|
+
|
19
|
+
Squares arguments are csv-like with commas separating elements and newlines separating rows.
|
20
|
+
|
21
|
+
Each element can be a colour, represented by a letter, or blank, represented by a dash.
|
22
|
+
|
23
|
+
```
|
24
|
+
grid = GridGenerator.iso_view(x: 20, y: 20, units: 20, top_squares: "-,-,-\\n-,-,R\\n-,-,W", front_squares: "-,-,R\\n-,b,-\\n-,b,-", right_squares: "B,B,-\\n-,r,-\\n-,r,-")
|
25
|
+
```
|
26
|
+
|
27
|
+
Serialized the data for use in svg polygon and line elements:
|
28
|
+
|
29
|
+
```
|
30
|
+
grid.as_json
|
31
|
+
```
|
22
32
|
|
23
33
|
## Development
|
24
34
|
|
@@ -28,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
38
|
|
29
39
|
## Contributing
|
30
40
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/grid_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mrlhumphreys/grid_generator/blob/main/CODE_OF_CONDUCT.md).
|
32
42
|
|
33
43
|
## License
|
34
44
|
|
@@ -36,4 +46,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
36
46
|
|
37
47
|
## Code of Conduct
|
38
48
|
|
39
|
-
Everyone interacting in the GridGenerator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
49
|
+
Everyone interacting in the GridGenerator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mrlhumphreys/grid_generator/blob/main/CODE_OF_CONDUCT.md).
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../face_parser'
|
2
|
+
require_relative 'common'
|
3
|
+
require_relative 'element_factory'
|
4
4
|
|
5
5
|
module GridGenerator
|
6
6
|
module Megaminx
|
data/lib/grid_generator.rb
CHANGED
@@ -2,23 +2,23 @@
|
|
2
2
|
|
3
3
|
require_relative "grid_generator/version"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
5
|
+
require_relative 'grid_generator/cubic/iso_view'
|
6
|
+
require_relative 'grid_generator/cubic/top_grid'
|
7
|
+
require_relative 'grid_generator/cubic/front_grid'
|
8
|
+
require_relative 'grid_generator/cubic/right_grid'
|
9
|
+
require_relative 'grid_generator/cubic/facing_grid'
|
10
|
+
require_relative 'grid_generator/cubic/bordered_grid'
|
11
|
+
require_relative 'grid_generator/cubic/square_factory'
|
12
|
+
require_relative 'grid_generator/skewb/top_skewb_grid'
|
13
|
+
require_relative 'grid_generator/skewb/left_skewb_grid'
|
14
|
+
require_relative 'grid_generator/skewb/right_skewb_grid'
|
15
|
+
require_relative 'grid_generator/square_one/face'
|
16
|
+
require_relative 'grid_generator/arrows/vertical_arrow'
|
17
|
+
require_relative 'grid_generator/arrows/horizontal_arrow'
|
18
|
+
require_relative 'grid_generator/arrows/diagonal_down_arrow'
|
19
|
+
require_relative 'grid_generator/arrows/diagonal_up_arrow'
|
20
|
+
require_relative 'grid_generator/pyraminx/grid'
|
21
|
+
require_relative 'grid_generator/megaminx/face'
|
22
22
|
|
23
23
|
module GridGenerator
|
24
24
|
def self.iso_view(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.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-02-
|
11
|
+
date: 2023-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matrix
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- lib/grid_generator/skewb/skewb_grid.rb
|
69
69
|
- lib/grid_generator/skewb/top_element_factory.rb
|
70
70
|
- lib/grid_generator/skewb/top_skewb_grid.rb
|
71
|
-
- lib/grid_generator/square_one/element.rb
|
72
71
|
- lib/grid_generator/square_one/element_factory.rb
|
73
72
|
- lib/grid_generator/square_one/face.rb
|
74
73
|
- lib/grid_generator/square_one_face_parser.rb
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'matrix'
|
2
|
-
|
3
|
-
module GridGenerator
|
4
|
-
module SquareOne
|
5
|
-
class Element
|
6
|
-
def initialize(x:, y:, units:, offset: , colour: , opacity: )
|
7
|
-
@x, @y = x, y
|
8
|
-
@units = units
|
9
|
-
@offset = offset
|
10
|
-
@colour = colour
|
11
|
-
@opacity = opacity
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_reader :x, :y, :units, :offset, :colour, :opacity
|
15
|
-
|
16
|
-
def ==(other)
|
17
|
-
self.x == other.x &&
|
18
|
-
self.y == other.y &&
|
19
|
-
self.units == other.units &&
|
20
|
-
self.colour == other.colour &&
|
21
|
-
self.opacity == other.opacity
|
22
|
-
end
|
23
|
-
|
24
|
-
def offset_radians
|
25
|
-
offset*Math::PI/6
|
26
|
-
end
|
27
|
-
|
28
|
-
def half_edge_width
|
29
|
-
@half_edge_width ||= half_face_size * Math.tan(Math::PI/12)
|
30
|
-
end
|
31
|
-
|
32
|
-
def half_face_size
|
33
|
-
@half_face_size ||= face_size / 2
|
34
|
-
end
|
35
|
-
|
36
|
-
def face_size
|
37
|
-
@face_size ||= 3 * units
|
38
|
-
end
|
39
|
-
|
40
|
-
def rotation_point
|
41
|
-
Matrix.column_vector([x+half_face_size, y+half_face_size])
|
42
|
-
end
|
43
|
-
|
44
|
-
def rotation_matrix
|
45
|
-
@rotation_matrix ||= Matrix[
|
46
|
-
[Math.cos(offset_radians), -1*Math.sin(offset_radians)],
|
47
|
-
[Math.sin(offset_radians), Math.cos(offset_radians)]
|
48
|
-
]
|
49
|
-
end
|
50
|
-
|
51
|
-
def points
|
52
|
-
base_points.map { |p| (rotation_matrix * (p - rotation_point)) + rotation_point }
|
53
|
-
end
|
54
|
-
|
55
|
-
def points_string
|
56
|
-
points.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|