| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package LaTeX::TikZ::Tools; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 10 |  |  | 10 |  | 58 | use strict; | 
|  | 10 |  |  |  |  | 20 |  | 
|  | 10 |  |  |  |  | 351 |  | 
| 4 | 10 |  |  | 10 |  | 58 | use warnings; | 
|  | 10 |  |  |  |  | 17 |  | 
|  | 10 |  |  |  |  | 497 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | =head1 NAME | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | LaTeX::TikZ::Tools - Miscellaneous tools for LaTeX::TikZ classes. | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | =head1 VERSION | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | Version 0.02 | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =cut | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | our $VERSION = '0.02'; | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 10 |  |  | 10 |  | 57 | use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ]; | 
|  | 10 |  |  |  |  | 16 |  | 
|  | 10 |  |  |  |  | 66 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head1 CONSTANTS | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =head2 C<EPS> | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =cut | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 10 |  |  | 10 |  | 2547 | use constant EPS => 1e-10; | 
|  | 10 |  |  |  |  | 19 |  | 
|  | 10 |  |  |  |  | 3135 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | =head2 C<numeq> | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =cut | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 220 |  |  | 220 | 1 | 1301 | sub numeq { abs($_[0] - $_[1]) < EPS } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =head2 C<numcmp> | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =cut | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 46 | 100 |  | 46 | 1 | 486 | sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 } | 
|  |  | 100 |  |  |  |  |  | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head2 C<numround> | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =cut | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub numround { | 
| 47 | 0 |  |  | 0 | 1 | 0 | my $x = $_[0]; | 
| 48 | 0 |  |  |  |  | 0 | my $i = int $x; | 
| 49 | 0 | 0 |  |  |  | 0 | $x + EPS < $i + 0.5 ? $i : $i + 1; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =head2 C<type_constraint $class> | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | Find the type constraint for C<$class> by loading the relevant F<.pm> file beforehand. | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | =cut | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub type_constraint { | 
| 59 | 135 |  |  | 135 | 1 | 239 | my ($class) = @_; | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 135 |  |  |  |  | 223 | my $file = $class; | 
| 62 | 135 |  |  |  |  | 620 | $file =~ s{::}{/}g; | 
| 63 | 135 |  |  |  |  | 274 | $file .= '.pm'; | 
| 64 | 135 |  |  |  |  | 29719 | require $file; | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 135 |  |  |  |  | 504 | find_type_constraint($class); | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | L<LaTeX::TikZ>. | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head1 AUTHOR | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>. | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | You can contact me by mail or on C<irc.perl.org> (vincent). | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head1 BUGS | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Please report any bugs or feature requests to C<bug-latex-tikz at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ>. | 
| 82 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =head1 SUPPORT | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | perldoc LaTeX::TikZ | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Copyright 2010 Vincent Pit, all rights reserved. | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =cut | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | 1; # End of LaTeX::TikZ::Tools |