1 package LaTeX::TikZ::Set::Point;
8 LaTeX::TikZ::Set::Point - A set object representing a point.
16 our $VERSION = '0.03';
18 use LaTeX::TikZ::Point;
20 use LaTeX::TikZ::Interface;
21 use LaTeX::TikZ::Functor;
24 use Mouse::Util::TypeConstraints;
28 This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
32 with 'LaTeX::TikZ::Set::Path';
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);
121 sub begin { $_[0]->point }
127 sub end { $_[0]->point }
129 LaTeX::TikZ::Interface->register(
138 } else { # @_ even, @_ >= 2
139 $point = [ shift, shift ];
142 __PACKAGE__->new(point => $point, @_);
146 LaTeX::TikZ::Functor->default_rule(
147 (__PACKAGE__) => sub {
148 my ($functor, $set, @args) = @_;
150 point => $set->point,
151 label => $set->label,
157 __PACKAGE__->meta->make_immutable;
161 L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
165 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
167 You can contact me by mail or on C<irc.perl.org> (vincent).
171 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>.
172 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
176 You can find documentation for this module with the perldoc command.
180 =head1 COPYRIGHT & LICENSE
182 Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.
184 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
188 1; # End of LaTeX::TikZ::Set::Point