]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Point.pm
Just use Mouse instead of Any::Moose
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Point.pm
1 package LaTeX::TikZ::Point;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 LaTeX::TikZ::Point - Internal representation of what LaTeX::TikZ consider as 2D points.
9
10 =head1 VERSION
11
12 Version 0.02
13
14 =cut
15
16 our $VERSION = '0.02';
17
18 use Mouse;
19 use Mouse::Util::TypeConstraints qw<
20  coerce from via
21  find_type_constraint
22  register_type_constraint
23 >;
24
25 =head1 ATTRIBUTES
26
27 =head2 C<x>
28
29 The abscissa of the point.
30
31 =cut
32
33 has 'x' => (
34  is       => 'ro',
35  isa      => 'Num',
36  required => 1,
37 );
38
39 =head2 C<y>
40
41 The ordinate of the point.
42
43 =cut
44
45 has 'y' => (
46  is       => 'ro',
47  isa      => 'Num',
48  required => 1,
49 );
50
51 use LaTeX::TikZ::Meta::TypeConstraint::Autocoerce;
52
53 register_type_constraint(
54  LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
55   name   => 'LaTeX::TikZ::Point::Autocoerce',
56   target => find_type_constraint(__PACKAGE__),
57  ),
58 );
59
60 coerce 'LaTeX::TikZ::Point::Autocoerce'
61     => from 'LaTeX::TikZ::Point'
62     => via { $_ };
63
64 coerce 'LaTeX::TikZ::Point::Autocoerce'
65     => from 'Num'
66     => via { LaTeX::TikZ::Point->new(x => $_, y => 0) };
67
68 coerce 'LaTeX::TikZ::Point::Autocoerce'
69     => from 'ArrayRef'
70     => via { LaTeX::TikZ::Point->new(x => $_->[0], y => $_->[1]) };
71
72 __PACKAGE__->meta->make_immutable;
73
74 =head1 SEE ALSO
75
76 L<LaTeX::TikZ>.
77
78 =head1 AUTHOR
79
80 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
81
82 You can contact me by mail or on C<irc.perl.org> (vincent).
83
84 =head1 BUGS
85
86 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>.
87 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
88
89 =head1 SUPPORT
90
91 You can find documentation for this module with the perldoc command.
92
93     perldoc LaTeX::TikZ
94
95 =head1 COPYRIGHT & LICENSE
96
97 Copyright 2010 Vincent Pit, all rights reserved.
98
99 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
100
101 =cut
102
103 1; # End of LaTeX::TikZ::Point