1 package LaTeX::TikZ::Tools;
8 LaTeX::TikZ::Tools - Miscellaneous tools for LaTeX::TikZ classes.
16 our $VERSION = '0.02';
18 use Mouse::Util::TypeConstraints 'find_type_constraint';
24 The numerical accuracy enforced by L</numeq>, L</numcmp> and L</numround>.
25 It is currently set to C<1e-10>.
29 use constant EPS => 1e-10;
37 Returns true if and only if C<$x> and C<$y> are equal up to L</EPS>.
41 sub numeq { abs($_[0] - $_[1]) < EPS }
47 Returns a negative number, zero, or a positive number when C<$x> is respectively smaller than, equal to, or greater than C<$y> up to L</EPS>.
51 sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 }
57 Returns the closest integer from C<$x> up to L</EPS>.
64 $x + EPS < $i + 0.5 ? $i : $i + 1;
67 =head2 C<type_constraint>
69 my $tc = type_constraint($class)
71 Finds the type constraint for C<$class> by first trying to load the relevant F<.pm> file.
81 unless ($INC{$file}) {
84 local $SIG{__DIE__}; # See LaTeX::TikZ::Meta::TypeConstraint::Autocoerce
89 find_type_constraint($class);
98 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
100 You can contact me by mail or on C<irc.perl.org> (vincent).
104 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>.
105 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
109 You can find documentation for this module with the perldoc command.
113 =head1 COPYRIGHT & LICENSE
115 Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.
117 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
121 1; # End of LaTeX::TikZ::Tools