]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Tools.pm
Initial commit
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Tools.pm
1 package LaTeX::TikZ::Tools;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 LaTeX::TikZ::Tools - Miscellanous tools for LaTeX::TikZ classes.
9
10 =head1 VERSION
11
12 Version 0.01
13
14 =cut
15
16 our $VERSION = '0.01';
17
18 use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ];
19
20 use constant EPS => 1e-10;
21
22 sub numeq { abs($_[0] - $_[1]) < EPS }
23
24 sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 }
25
26 sub numround {
27  my $x = $_[0];
28  my $i = int $x;
29  $x + EPS < $i + 0.5 ? $i : $i + 1;
30 }
31
32 sub type_constraint {
33  my ($class) = @_;
34
35  my $file = $class;
36  $file =~ s{::}{/}g;
37  $file .= '.pm';
38  require $file;
39
40  find_type_constraint($class);
41 }
42
43 =head1 AUTHOR
44
45 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
46
47 You can contact me by mail or on C<irc.perl.org> (vincent).
48
49 =head1 BUGS
50
51 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>.
52 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
53
54 =head1 SUPPORT
55
56 You can find documentation for this module with the perldoc command.
57
58     perldoc LaTeX::TikZ
59
60 =head1 COPYRIGHT & LICENSE
61
62 Copyright 2010 Vincent Pit, all rights reserved.
63
64 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
65
66 =cut
67
68 1; # End of LaTeX::TikZ::Tools