X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FPoint.pm;h=54a158e3662cc7c0ab3389365c6480df53208c42;hb=4f696c03a66ef6b52ee7b9b3c74a71d5abc64f7e;hp=f2155e8ff75b151ef0e83b45361c0047d8913e73;hpb=e8f0879ade07eed4f58cd52c0771f4e1ecc90b09;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Point.pm b/lib/LaTeX/TikZ/Point.pm index f2155e8..54a158e 100644 --- a/lib/LaTeX/TikZ/Point.pm +++ b/lib/LaTeX/TikZ/Point.pm @@ -5,23 +5,76 @@ use warnings; =head1 NAME -LaTeX::TikZ::Point - Interface role for what LaTeX::TikZ consider as 2D points. +LaTeX::TikZ::Point - Internal representation of what LaTeX::TikZ consider as 2D points. =head1 VERSION -Version 0.01 +Version 0.03 =cut -our $VERSION = '0.01'; +our $VERSION = '0.03'; -use Any::Moose 'Role'; +use Mouse; +use Mouse::Util::TypeConstraints qw< + coerce from via + find_type_constraint + register_type_constraint +>; -requires qw( - x - y +=head1 ATTRIBUTES + +=head2 C + +The abscissa of the point. + +=cut + +has 'x' => ( + is => 'ro', + isa => 'Num', + required => 1, +); + +=head2 C + +The ordinate of the point. + +=cut + +has 'y' => ( + is => 'ro', + isa => 'Num', + required => 1, ); +use LaTeX::TikZ::Meta::TypeConstraint::Autocoerce; + +register_type_constraint( + LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new( + name => 'LaTeX::TikZ::Point::Autocoerce', + target => find_type_constraint(__PACKAGE__), + ), +); + +coerce 'LaTeX::TikZ::Point::Autocoerce' + => from 'LaTeX::TikZ::Point' + => via { $_ }; + +coerce 'LaTeX::TikZ::Point::Autocoerce' + => from 'Num' + => via { LaTeX::TikZ::Point->new(x => $_, y => 0) }; + +coerce 'LaTeX::TikZ::Point::Autocoerce' + => from 'ArrayRef' + => via { LaTeX::TikZ::Point->new(x => $_->[0], y => $_->[1]) }; + +__PACKAGE__->meta->make_immutable; + +=head1 SEE ALSO + +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. @@ -41,7 +94,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2010 Vincent Pit, all rights reserved. +Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.