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