line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LaTeX::TikZ::Tools; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
40
|
use strict; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
306
|
|
4
|
11
|
|
|
11
|
|
40
|
use warnings; |
|
11
|
|
|
|
|
12
|
|
|
11
|
|
|
|
|
318
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
LaTeX::TikZ::Tools - Miscellaneous tools for LaTeX::TikZ classes. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.03 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
17
|
|
|
|
|
|
|
|
18
|
11
|
|
|
11
|
|
406
|
use Mouse::Util::TypeConstraints 'find_type_constraint'; |
|
11
|
|
|
|
|
11619
|
|
|
11
|
|
|
|
|
50
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 CONSTANTS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 C |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The numerical accuracy enforced by L, L and L. |
25
|
|
|
|
|
|
|
It is currently set to C<1e-10>. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
|
11
|
|
665
|
use constant EPS => 1e-10; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
2186
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 FUNCTIONS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 C |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
numeq($x, $y) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Returns true if and only if C<$x> and C<$y> are equal up to L. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
270
|
|
|
270
|
1
|
823
|
sub numeq { abs($_[0] - $_[1]) < EPS } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 C |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
numcmp($x, $y) |
46
|
|
|
|
|
|
|
|
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. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
46
|
100
|
|
46
|
1
|
264
|
sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 } |
|
|
100
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
numround($x) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns the closest integer from C<$x> up to L. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub numround { |
62
|
0
|
|
|
0
|
1
|
0
|
my $x = $_[0]; |
63
|
0
|
|
|
|
|
0
|
my $i = int $x; |
64
|
0
|
0
|
|
|
|
0
|
$x + EPS < $i + 0.5 ? $i : $i + 1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 C |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $tc = type_constraint($class) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Finds the type constraint for C<$class> by first trying to load the relevant F<.pm> file. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub type_constraint { |
76
|
161
|
|
|
161
|
1
|
167
|
my ($class) = @_; |
77
|
|
|
|
|
|
|
|
78
|
161
|
|
|
|
|
153
|
my $file = $class; |
79
|
161
|
|
|
|
|
507
|
$file =~ s{::}{/}g; |
80
|
161
|
|
|
|
|
168
|
$file .= '.pm'; |
81
|
161
|
100
|
|
|
|
344
|
unless ($INC{$file}) { |
82
|
31
|
|
|
|
|
60
|
local $@; |
83
|
31
|
|
|
|
|
59
|
eval { |
84
|
31
|
|
|
|
|
129
|
local $SIG{__DIE__}; # See LaTeX::TikZ::Meta::TypeConstraint::Autocoerce |
85
|
31
|
|
|
|
|
9719
|
require $file; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
161
|
|
|
|
|
380
|
find_type_constraint($class); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 BUGS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
105
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SUPPORT |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
perldoc LaTeX::TikZ |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; # End of LaTeX::TikZ::Tools |