=head1 NAME
-LaTeX::TikZ::Set::Polyline - A set object representing a line.
+LaTeX::TikZ::Set::Polyline - A set object representing a possibly closed path composed of contiguous lines.
=head1 VERSION
-Version 0.01
+Version 0.02
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
use LaTeX::TikZ::Set::Point;
use Any::Moose;
use Any::Moose 'Util::TypeConstraints';
-with 'LaTeX::TikZ::Set::Op';
+=head1 RELATIONSHIPS
+
+This class is a subclass of L<LaTeX::TikZ::Set::Chain>, and as such inherits its C<path> method.
+
+=cut
+
+extends 'LaTeX::TikZ::Set::Chain';
subtype 'LaTeX::TikZ::Set::Polyline::Vertices'
=> as 'ArrayRef[LaTeX::TikZ::Set::Point]'
=> from 'ArrayRef[Any]'
=> via { [ map LaTeX::TikZ::Set::Point->new(point => $_), @$_ ] };
-has '_points' => (
+=head1 ATTRIBUTES
+
+=head2 C<points>
+
+The list of L<LaTeX::TikZ::Set::Point> objects (or scalars that coerce into such objects) that make the successive vertices of the path.
+
+=cut
+
+has '+_kids' => (
is => 'ro',
isa => 'LaTeX::TikZ::Set::Polyline::Vertices',
init_arg => 'points',
coerce => 1,
);
-sub points { @{$_[0]->_points} }
+sub points { @{$_[0]->_kids} }
-has 'closed' => (
- is => 'ro',
- isa => 'Bool',
- default => 0,
-);
-
-sub path {
- my $set = shift;
+around 'BUILDARGS' => sub {
+ my ($orig, $class, %args) = @_;
- join ' -- ', map($_->path(@_), $set->points),
- ($set->closed ? 'cycle' : ());
-}
+ $class->$orig(
+ %args,
+ connector => '--',
+ );
+};
LaTeX::TikZ::Interface->register(
polyline => sub {
closed_polyline => sub {
shift;
- __PACKAGE__->new(points => \@_, closed => 1);
- },
-);
-
-LaTeX::TikZ::Functor->default_rule(
- (__PACKAGE__) => sub {
- my ($functor, $set, @args) = @_;
- $set->new(
- points => [ map $_->$functor(@args), $set->points ],
- closed => $set->closed,
+ __PACKAGE__->new(
+ points => \@_,
+ cycle => 1
);
- }
+ },
);
__PACKAGE__->meta->make_immutable;
+=head1 SEE ALSO
+
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Chain>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.