]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Set/Circle.pm
f1bbeab30a9a5942537418fd209c1be1591596ec
[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::Tools;
21
22 use Any::Moose;
23 use Any::Moose 'Util::TypeConstraints';
24
25 with 'LaTeX::TikZ::Set::Op';
26
27 has 'center' => (
28  is       => 'ro',
29  isa      => 'LaTeX::TikZ::Set::Point',
30  required => 1,
31  coerce   => 1,
32 );
33
34 subtype 'LaTeX::TikZ::Set::Circle::Radius'
35      => as 'Num'
36      => where { LaTeX::TikZ::Tools::numcmp($_, 0) >= 1 }
37      => message { "$_ isn't a non-negative real number" };
38
39 has 'radius' => (
40  is       => 'ro',
41  isa      => 'LaTeX::TikZ::Set::Circle::Radius',
42  required => 1,
43 );
44
45 sub path {
46  my $set  = shift;
47  my $tikz = $_[0];
48
49  $set->center->path(@_) . ' circle (' . $tikz->len($set->radius) . ')';
50 }
51
52 use LaTeX::TikZ::Interface circle => sub {
53  shift;
54
55  __PACKAGE__->new(center => $_[0], radius => $_[1]);
56 };
57
58 __PACKAGE__->meta->make_immutable;
59
60 =head1 AUTHOR
61
62 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
63
64 You can contact me by mail or on C<irc.perl.org> (vincent).
65
66 =head1 BUGS
67
68 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>.
69 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
70
71 =head1 SUPPORT
72
73 You can find documentation for this module with the perldoc command.
74
75     perldoc LaTeX::TikZ
76
77 =head1 COPYRIGHT & LICENSE
78
79 Copyright 2010 Vincent Pit, all rights reserved.
80
81 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
82
83 =cut
84
85 1; # End of LaTeX::TikZ::Set::Circle