line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1029
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
2
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
3
|
|
|
|
|
|
|
package Math::HexGrid; |
4
|
|
|
|
|
|
|
$Math::HexGrid::VERSION = '0.01'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Math::HexGrid - create hex coordinate grids |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
709
|
use Math::HexGrid::Hex; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
8
|
1
|
|
|
1
|
|
7
|
use List::Util qw/min max/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
377
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new_hexagon |
14
|
|
|
|
|
|
|
{ |
15
|
1
|
|
|
1
|
1
|
496
|
my ($class, $radius) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
3
|
my %map; |
18
|
1
|
|
|
|
|
5
|
for (my $q = - $radius; $q <= $radius; $q++) |
19
|
|
|
|
|
|
|
{ |
20
|
5
|
|
|
|
|
21
|
my $r1 = max(-$radius, -$q - $radius); |
21
|
5
|
|
|
|
|
11
|
my $r2 = min($radius, -$q + $radius); |
22
|
|
|
|
|
|
|
|
23
|
5
|
|
|
|
|
16
|
for (my $r = $r1; $r <= $r2; $r++) |
24
|
|
|
|
|
|
|
{ |
25
|
19
|
|
|
|
|
60
|
$map{"$q$r"} = Math::HexGrid::Hex->new($q, $r); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
8
|
bless { |
30
|
|
|
|
|
|
|
map => \%map, |
31
|
|
|
|
|
|
|
}, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get_hex |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
1
|
|
my ($self, $q, $r) = @_; |
38
|
0
|
|
|
|
|
|
$self->{map}{"$q$r"}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |