1 package LaTeX::TikZ::Mod::Pattern;
8 LaTeX::TikZ::Mod::Pattern - A modifier that fills a closed path with a pattern.
16 our $VERSION = '0.02';
18 use LaTeX::TikZ::Interface;
24 This class consumes the L<LaTeX::TikZ::Mod> role, and as such implements the L</tag>, L</covers>, L</declare> and L</apply> methods.
28 with 'LaTeX::TikZ::Mod';
38 isa => 'ArrayRef[Str]',
46 default => sub { +{ } },
56 my ($pat, $tikz) = @_;
58 my $cache = $pat->_cache->{$tikz->id};
59 confess('Template not yet declared') unless defined $cache;
67 name => sub { $_[0]->name($_[1]) },
68 width => sub { sprintf '%0.1fpt', $_[1]->thickness($_[2]) },
88 my ($pat, $tikz) = @_;
90 my $tikz_id = $tikz->id;
91 my $cache = $pat->_cache->{$tikz_id};
92 return @{$cache->[1]} if defined $cache;
94 $cache = $pat->_cache->{$tikz_id} = [ ];
95 $cache->[0] = 'pat' . $id++;
97 my $template = [ map $_, @{$pat->template} ];
99 my ($command, @opts) = split /=/, $1, 2;
100 @opts = split /,/, $opts[0] if @opts;
101 $handlers{lc $command}->($pat, $tikz, @opts);
103 $cache->[1] = $template;
112 sub apply { 'fill', 'pattern=' . $_[0]->name($_[1]) }
114 LaTeX::TikZ::Interface->register(
119 if (exists $args{class}) {
120 $class = delete $args{class};
121 $class = __PACKAGE__ . '::' . $class unless $class =~ /::/;
122 (my $pm = $class) =~ s{::}{/}g;
131 __PACKAGE__->meta->make_immutable;
135 L<LaTeX::TikZ>, L<LaTeX::TikZ::Mod>.
139 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
141 You can contact me by mail or on C<irc.perl.org> (vincent).
145 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>.
146 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
150 You can find documentation for this module with the perldoc command.
154 =head1 COPYRIGHT & LICENSE
156 Copyright 2010 Vincent Pit, all rights reserved.
158 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
162 1; # End of LaTeX::TikZ::Mod::Pattern