1 package LaTeX::TikZ::Set::Point;
8 LaTeX::TikZ::Set::Point - A set object representing a point.
16 our $VERSION = '0.01';
18 use LaTeX::TikZ::Point;
20 use LaTeX::TikZ::Interface;
21 use LaTeX::TikZ::Functor;
24 use Any::Moose 'Util::TypeConstraints';
28 This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
32 with 'LaTeX::TikZ::Set::Op';
38 The L<LaTeX::TikZ::Point> object representing the underlying geometrical point.
44 isa => 'LaTeX::TikZ::Point::Autocoerce',
47 handles => [ qw/x y/ ],
52 An optional label for the point.
64 The position of the label around the point.
68 enum 'LaTeX::TikZ::Set::Point::Positions' => (
81 isa => 'Maybe[LaTeX::TikZ::Set::Point::Positions]',
84 coerce 'LaTeX::TikZ::Set::Point'
86 => via { __PACKAGE__->new(point => $_) };
88 coerce 'LaTeX::TikZ::Point::Autocoerce'
89 => from 'LaTeX::TikZ::Set::Point'
99 my ($set, $tikz) = @_;
103 my $path = '(' . $tikz->len($p->x) . ',' . $tikz->len($p->y) . ')';
105 my $label = $set->label;
106 if (defined $label) {
108 $pos = 'above' unless defined $pos;
110 my $size = sprintf '%0.1fpt', 2 * $tikz->scale / 5;
111 $path .= " [fill] circle ($size) " . $tikz->label($label, $pos);
117 LaTeX::TikZ::Interface->register(
126 } else { # @_ even, @_ >= 2
127 $point = [ shift, shift ];
130 __PACKAGE__->new(point => $point, @_);
134 LaTeX::TikZ::Functor->default_rule(
135 (__PACKAGE__) => sub {
136 my ($functor, $set, @args) = @_;
138 point => $set->point,
139 label => $set->label,
145 __PACKAGE__->meta->make_immutable;
149 L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>.
153 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
155 You can contact me by mail or on C<irc.perl.org> (vincent).
159 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>.
160 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
164 You can find documentation for this module with the perldoc command.
168 =head1 COPYRIGHT & LICENSE
170 Copyright 2010 Vincent Pit, all rights reserved.
172 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
176 1; # End of LaTeX::TikZ::Set::Point