X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FPolyline.pm;h=445beb55022d839f1e0be476f159a11813e60c39;hb=3661d7849ae4636b74000e33e068493d90ed8337;hp=ef339e4d9a213e8600b721b0d8fd10075faa51e7;hpb=080eb1e263eb7c3700a9ebfd96522eaa534a0b6c;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Polyline.pm b/lib/LaTeX/TikZ/Set/Polyline.pm index ef339e4..445beb5 100644 --- a/lib/LaTeX/TikZ/Set/Polyline.pm +++ b/lib/LaTeX/TikZ/Set/Polyline.pm @@ -5,22 +5,31 @@ use warnings; =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'; +use LaTeX::TikZ::Interface; +use LaTeX::TikZ::Functor; -with 'LaTeX::TikZ::Set::Op'; +use Mouse; +use Mouse::Util::TypeConstraints; + +=head1 RELATIONSHIPS + +This class is a subclass of L, and as such inherits its C method. + +=cut + +extends 'LaTeX::TikZ::Set::Chain'; subtype 'LaTeX::TikZ::Set::Polyline::Vertices' => as 'ArrayRef[LaTeX::TikZ::Set::Point]' @@ -31,7 +40,15 @@ coerce 'LaTeX::TikZ::Set::Polyline::Vertices' => from 'ArrayRef[Any]' => via { [ map LaTeX::TikZ::Set::Point->new(point => $_), @$_ ] }; -has '_points' => ( +=head1 ATTRIBUTES + +=head2 C + +The list of L 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', @@ -39,34 +56,38 @@ has '_points' => ( coerce => 1, ); -sub points { @{$_[0]->_points} } +sub points { @{$_[0]->_kids} } -has 'closed' => ( - is => 'ro', - isa => 'Bool', - default => 0, -); +around 'BUILDARGS' => sub { + my ($orig, $class, %args) = @_; -sub path { - my $set = shift; + $class->$orig( + %args, + connector => '--', + ); +}; - join ' -- ', map($_->path(@_), $set->points), - ($set->closed ? 'cycle' : ()); -} +LaTeX::TikZ::Interface->register( + polyline => sub { + shift; -use LaTeX::TikZ::Interface polyline => sub { - shift; + __PACKAGE__->new(points => \@_); + }, + closed_polyline => sub { + shift; - __PACKAGE__->new(points => \@_); -}; + __PACKAGE__->new( + points => \@_, + cycle => 1 + ); + }, +); -use LaTeX::TikZ::Interface closed_polyline => sub { - shift; +__PACKAGE__->meta->make_immutable; - __PACKAGE__->new(points => \@_, closed => 1); -}; +=head1 SEE ALSO -__PACKAGE__->meta->make_immutable; +L, L. =head1 AUTHOR