File Coverage

blib/lib/LaTeX/TikZ/Set/Circle.pm
Criterion Covered Total %
statement 29 31 93.5
branch n/a
condition n/a
subroutine 10 12 83.3
pod 3 4 75.0
total 42 47 89.3


line stmt bran cond sub pod time code
1             package LaTeX::TikZ::Set::Circle;
2              
3 10     10   41 use strict;
  10         13  
  10         275  
4 10     10   35 use warnings;
  10         15  
  10         339  
5              
6             =head1 NAME
7              
8             LaTeX::TikZ::Set::Circle - A set object representing a circle.
9              
10             =head1 VERSION
11              
12             Version 0.03
13              
14             =cut
15              
16             our $VERSION = '0.03';
17              
18 10     10   35 use LaTeX::TikZ::Set::Point;
  10         12  
  10         128  
19              
20 10     10   33 use LaTeX::TikZ::Interface;
  10         12  
  10         144  
21 10     10   38 use LaTeX::TikZ::Functor;
  10         15  
  10         178  
22              
23 10     10   34 use LaTeX::TikZ::Tools;
  10         10  
  10         145  
24              
25 10     10   35 use Mouse;
  10         16  
  10         41  
26 10     10   2157 use Mouse::Util::TypeConstraints;
  10         13  
  10         50  
27              
28             =head1 RELATIONSHIPS
29              
30             This class consumes the L role, and as such implements the L method.
31              
32             =cut
33              
34             with 'LaTeX::TikZ::Set::Path';
35              
36             =head1 ATTRIBUTES
37              
38             =head2 C
39              
40             A L 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
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
66              
67             =cut
68              
69             sub path {
70 13     13 1 19 my $set = shift;
71 13         10 my $tikz = $_[0];
72              
73 13         48 $set->center->path(@_) . ' circle (' . $tikz->len($set->radius) . ')';
74             }
75              
76             =head2 C
77              
78             =cut
79              
80 0     0 1 0 sub begin { $_[0]->center->begin }
81              
82             =head2 C
83              
84             =cut
85              
86 0     0 1 0 sub end { $_[0]->center->end }
87              
88             LaTeX::TikZ::Interface->register(
89             circle => sub {
90 8     8 0 5354 shift;
91              
92 8         74 __PACKAGE__->new(center => $_[0], radius => $_[1]);
93             },
94             );
95              
96             LaTeX::TikZ::Functor->default_rule(
97             (__PACKAGE__) => sub {
98             my ($functor, $set, @args) = @_;
99             $set->new(
100             center => $set->center->$functor(@args),
101             radius => $set->radius,
102             );
103             }
104             );
105              
106             __PACKAGE__->meta->make_immutable;
107              
108             =head1 SEE ALSO
109              
110             L, L, L.
111              
112             =head1 AUTHOR
113              
114             Vincent Pit, C<< >>, L.
115              
116             You can contact me by mail or on C (vincent).
117              
118             =head1 BUGS
119              
120             Please report any bugs or feature requests to C, or through the web interface at L.
121             I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
122              
123             =head1 SUPPORT
124              
125             You can find documentation for this module with the perldoc command.
126              
127             perldoc LaTeX::TikZ
128              
129             =head1 COPYRIGHT & LICENSE
130              
131             Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.
132              
133             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
134              
135             =cut
136              
137             1; # End of LaTeX::TikZ::Set::Circle