SVG/RectHex.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 100% 46 / 46 CC 2 SCAR 1.8
CC
2
Cov
100%
convert_sign_position
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« SVG/Hex.pm ↑ Summary
1 # SVG maze output
2 # Performs transformation, cleanup, and printing of output of Games::Maze
3  
4 package Games::Maze::SVG::RectHex;
5  
6 28 ▶use base Games::Maze::SVG::HexCells;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 28 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 28 ▶use Games::Maze;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 Games::Maze::SVG::RectHex - Build rectangular mazes with hexagonal cells in SVG.
16  
17 =head1 VERSION
18  
19 Version 0.90
20  
21 =cut
22  
23 28 our $VERSION = 0.90;
24  
25 =head1 SYNOPSIS
26  
27 Games::Maze::SVG::RectHex uses the Games::Maze module to create mazes in SVG.
28  
29 use Games::Maze::SVG;
30  
31 my $foo = Games::Maze::SVG->new( 'RectHex' );
32 ...
33  
34 =head1 FUNCTIONS
35  
36 =cut
37  
38 # ----------------------------------------------
39 # Subroutines
40  
41 =over 4
42  
43 =item new
44  
45 Create a new Games::Maze::SVG object. Supports the following named parameters:
46  
47 Takes one positional parameter that is the maze type: Rect, RectHex, or Hex
48  
49 =over 4
50  
51 =item wallform
52  
53 String naming the wall format. Legal values are bevel, round, roundcorners,
54 and straight.
55  
56 =item crumb
57  
58 String describing the breadcrumb design. Legal values are dash,
59 dot, line, and none
60  
61 =item dx
62  
63 The size of the tiles in the X direction.
64  
65 =item dy
66  
67 The size of the tiles in the Y direction.
68  
69 =item dir
70  
71 Directory in which to find the ecmascript for the maze interactivity. Should
72 either be relative, or in URL form.
73  
74 =back
75  
76 =cut
77  
78 sub new
79 8 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
80 8 my $class = shift;
81  
82 8 my $obj = Games::Maze::SVG::HexCells->new( @_ );
83 7 $obj->{mazeparms}->{form} = 'Rectangle';
84
85 # rebless into this class.
86 7 return bless $obj, $class;
87 }
88  
89  
90 =item is_hex
91  
92 Method returns true.
93  
94 =cut
95  
96 sub is_hex
97 1 ▶{
Subroutine is_hex: called CC=1 SCAR=0.0
Pod documented
98 1 return 1;
99 }
100  
101  
102 =item is_hex_shaped
103  
104 Method returns false.
105  
106 =cut
107  
108 sub is_hex_shaped
109 1 ▶{
Subroutine is_hex_shaped: called CC=1 SCAR=0.0
Pod documented
110 1 return;
111 }
112  
113  
114 =item convert_sign_position
115  
116 Convert the supplied x and y coordinates into the appropriate real coordinates
117 for a the position of the exit sign.
118  
119 =over 4
120  
121 =item $x x coord from the maze
122  
123 =item $y y coord from the maze
124  
125 =back
126  
127 returns a two element list containing (x, y).
128  
129 =cut
130  
131 sub convert_sign_position
132 4 ▶{
Subroutine convert_sign_position: called CC=2 SCAR=6.9
Pod documented
133 4 my $self = shift;
134 4 my ($x, $y) = @_;
135  
136 4 $x *= $self->dx();
137 4 $y *= $self->dy();
138  
139 # adjust bottom
140 4 ▶ if($y > $self->{height}/2)
Branch: 1 branch
BranchTrueFalseTotal
if ($y > $self->{'height'} / 2) { } 2 2 4
141 {
142 2 $y += 2*$self->dy();
143 }
144 else
145 {
146 2 $y -= $self->dy();
147 }
148  
149 4 return ($x, $y);
150 }
151  
152 =back
153  
154 =head1 AUTHOR
155  
156 G. Wade Johnson, C<< <wade@anomaly.org> >>
157  
158 =head1 BUGS
159  
160 Please report any bugs or feature requests to
161 C<bug-game-maze-svg@rt.cpan.org>, or through the web interface at
162 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-Maze-SVG>.
163 I will be notified, and then you'll automatically be notified of progress on
164 your bug as I make changes.
165  
166 =head1 ACKNOWLEDGEMENTS
167  
168 Thanks go to Valen Johnson and Jason Wood for extensive test play of the
169 mazes.
170  
171 =head1 COPYRIGHT & LICENSE
172  
173 Copyright 2004-2006 G. Wade Johnson, all rights reserved.
174  
175 This program is free software; you can redistribute it and/or modify it
176 under the same terms as Perl itself.
177  
178 =cut
179  
180 28 1;
« SVG/Hex.pm ↑ Summary