rhex 1.2.2 → 1.2.3
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/lib/hex/ascii_to_grid.rb +8 -9
- data/lib/hex/grid.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a2e40d08cd8b0af78d794a06edabe792d504d1d
|
4
|
+
data.tar.gz: 5f4c074aa457e00505c5c5bad0a2721d55a27180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2bf038530231da4e29dc9626062a0d2935b522de5b84bb60aa39aa5faffd0f65888571fd3c125fe20d97e850424e81c503eb25ac98c4b9943e298b43345c82b
|
7
|
+
data.tar.gz: 131308282edb5a1a3bb3b6e408884eb1a18c04e3f8b73b6d952014cf879e526e59b74ccbf2566a3e87bcef493db57cf1936093c48ebc0f4e444a2f79e656692e
|
data/lib/hex/ascii_to_grid.rb
CHANGED
@@ -6,30 +6,29 @@ module AsciiToGrid
|
|
6
6
|
def read_ascii_file( file_path )
|
7
7
|
File.open( file_path ) do |file|
|
8
8
|
|
9
|
-
r =
|
9
|
+
r = max_r = 0
|
10
|
+
|
10
11
|
file.each_line do |line|
|
11
12
|
elements = line.split
|
12
13
|
q = 0
|
13
14
|
elements.each do |element|
|
14
15
|
border = true if ( r == 0 || q == 0 )
|
15
|
-
|
16
|
+
shifted_q = q - ( r/2 )
|
17
|
+
cset( shifted_q, r, val: element, border: border )
|
16
18
|
q += 1
|
17
|
-
max_q = [ max_q, q ].max
|
18
19
|
end
|
19
20
|
r += 1
|
20
21
|
max_r = [ max_r, r ].max
|
21
22
|
end
|
22
23
|
|
23
|
-
0.upto( max_q - 1 ).each do |q|
|
24
|
-
hex = cget( q, max_r - 1 )
|
25
|
-
hex.border! if hex
|
26
|
-
end
|
27
|
-
|
28
24
|
0.upto( max_r - 1 ).each do |row|
|
29
|
-
|
25
|
+
maxq = @hexes.map{ |key, e| e.q if e.r == row }.compact.max
|
26
|
+
hex = cget( maxq, row )
|
30
27
|
hex.border! if hex
|
31
28
|
end
|
32
29
|
|
30
|
+
@hexes.each{ |key, e| e.border! if e.r == ( max_r - 1 ) }
|
31
|
+
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
data/lib/hex/grid.rb
CHANGED
@@ -71,14 +71,14 @@ module Hex
|
|
71
71
|
q = (x * Math.sqrt(3)/3.0 - y/3.0) / @hex_ray
|
72
72
|
r = y * 2.0/3.0 / @hex_ray
|
73
73
|
hex = Hex::Axial.new(q, r).round
|
74
|
-
|
74
|
+
cget( hex.q, hex.r )
|
75
75
|
end
|
76
76
|
|
77
77
|
# Give the position of an hexagon object in pixel.
|
78
78
|
#
|
79
79
|
# *Returns* : an array of x, y positions.
|
80
80
|
def to_xy( hex )
|
81
|
-
tmp_q = hex.q
|
81
|
+
tmp_q = hex.q
|
82
82
|
x = @hex_ray * Math.sqrt(3) * ( tmp_q + hex.r/2.0 )
|
83
83
|
y = @hex_ray * 3.0/2.0 * hex.r
|
84
84
|
[ x, y ]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cédric ZUGER
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
A library providing hexagons management and hexagonal grids for ruby.
|
@@ -25,7 +25,7 @@ files:
|
|
25
25
|
- lib/hex/grid.rb
|
26
26
|
- lib/hex/grid_to_pic.rb
|
27
27
|
- lib/rhex.rb
|
28
|
-
homepage:
|
28
|
+
homepage: https://github.com/czuger/rhex
|
29
29
|
licenses:
|
30
30
|
- MIT
|
31
31
|
metadata: {}
|