]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Set/Circle.pm
First cut at the documentation
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Circle.pm
1 package LaTeX::TikZ::Set::Circle;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 LaTeX::TikZ::Set::Circle - A set object representing a circle.
9
10 =head1 VERSION
11
12 Version 0.01
13
14 =cut
15
16 our $VERSION = '0.01';
17
18 use LaTeX::TikZ::Set::Point;
19
20 use LaTeX::TikZ::Interface;
21 use LaTeX::TikZ::Functor;
22
23 use LaTeX::TikZ::Tools;
24
25 use Any::Moose;
26 use Any::Moose 'Util::TypeConstraints';
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  my $set  = shift;
71  my $tikz = $_[0];
72
73  $set->center->path(@_) . ' circle (' . $tikz->len($set->radius) . ')';
74 }
75
76 LaTeX::TikZ::Interface->register(
77  circle => sub {
78   shift;
79
80   __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 AUTHOR
97
98 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
99
100 You can contact me by mail or on C<irc.perl.org> (vincent).
101
102 =head1 BUGS
103
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.
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 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::Set::Circle