File Coverage

blib/lib/LaTeX/TikZ/Set/Circle.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 1 2 50.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package LaTeX::TikZ::Set::Circle;
2              
3 10     10   56 use strict;
  10         21  
  10         341  
4 10     10   58 use warnings;
  10         18  
  10         423  
5              
6             =head1 NAME
7              
8             LaTeX::TikZ::Set::Circle - A set object representing a circle.
9              
10             =head1 VERSION
11              
12             Version 0.02
13              
14             =cut
15              
16             our $VERSION = '0.02';
17              
18 10     10   53 use LaTeX::TikZ::Set::Point;
  10         18  
  10         233  
19              
20 10     10   52 use LaTeX::TikZ::Interface;
  10         20  
  10         222  
21 10     10   66 use LaTeX::TikZ::Functor;
  10         39  
  10         227  
22              
23 10     10   58 use LaTeX::TikZ::Tools;
  10         45  
  10         256  
24              
25 10     10   53 use Any::Moose;
  10         29  
  10         60  
26 10     10   5037 use Any::Moose 'Util::TypeConstraints';
  10         19  
  10         42  
27              
28             =head1 RELATIONSHIPS
29              
30             This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
31              
32             =cut
33              
34             with 'LaTeX::TikZ::Set::Op';
35              
36             =head1 ATTRIBUTES
37              
38             =head2 C<center>
39              
40             A L<LaTeX::TikZ::Set::Point> object describing the center of the circle.
41              
42             =cut
43              
44             has 'center' => (
45             is => 'ro',
46             isa => 'LaTeX::TikZ::Set::Point',
47             required => 1,
48             coerce => 1,
49             );
50              
51             =head2 C<radius>
52              
53             The radius of the circle as a non-negative real number.
54              
55             =cut
56              
57             has 'radius' => (
58             is => 'ro',
59             isa => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) > 0 }),
60             required => 1,
61             );
62              
63             =head1 METHODS
64              
65             =head2 C<path>
66              
67             =cut
68              
69             sub path {
70 13     13 1 24 my $set = shift;
71 13         23 my $tikz = $_[0];
72              
73 13         82 $set->center->path(@_) . ' circle (' . $tikz->len($set->radius) . ')';
74             }
75              
76             LaTeX::TikZ::Interface->register(
77             circle => sub {
78 8     8 0 7681 shift;
79              
80 8         317 __PACKAGE__->new(center => $_[0], radius => $_[1]);
81             },
82             );
83              
84             LaTeX::TikZ::Functor->default_rule(
85             (__PACKAGE__) => sub {
86             my ($functor, $set, @args) = @_;
87             $set->new(
88             center => $set->center->$functor(@args),
89             radius => $set->radius,
90             );
91             }
92             );
93              
94             __PACKAGE__->meta->make_immutable;
95              
96             =head1 SEE ALSO
97              
98             L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>, L<LaTeX::TikZ::Set::Op>.
99              
100             =head1 AUTHOR
101              
102             Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
103              
104             You can contact me by mail or on C<irc.perl.org> (vincent).
105              
106             =head1 BUGS
107              
108             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>.
109             I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
110              
111             =head1 SUPPORT
112              
113             You can find documentation for this module with the perldoc command.
114              
115             perldoc LaTeX::TikZ
116              
117             =head1 COPYRIGHT & LICENSE
118              
119             Copyright 2010 Vincent Pit, all rights reserved.
120              
121             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
122              
123             =cut
124              
125             1; # End of LaTeX::TikZ::Set::Circle