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.01';
20 with 'LaTeX::TikZ::Mod';
32 default => sub { +{ } },
36 my ($pat, $tikz) = @_;
38 my $cache = $pat->_cache->{$tikz->id};
39 confess('Template not yet declared') unless defined $cache;
47 name => sub { $_[0]->name($_[1]) },
48 width => sub { sprintf '%0.1fpt', $_[1]->thickness($_[2]) },
56 my ($pat, $tikz) = @_;
58 my $tikz_id = $tikz->id;
59 my $cache = $pat->_cache->{$tikz_id};
60 return $cache->[1] if defined $cache;
61 $cache = $pat->_cache->{$tikz_id} = [ ];
63 $cache->[0] = 'pat' . $id++;
65 my $template = $pat->template;
66 $template =~ s!#([^#]+)#!
67 my ($command, @opts) = split /=/, $1, 2;
68 @opts = split /,/, $opts[0] if @opts;
69 $handlers{lc $command}->($pat, $tikz, @opts);
71 $cache->[1] = $template;
74 sub apply { 'fill', 'pattern=' . $_[0]->name($_[1]) }
76 __PACKAGE__->meta->make_immutable;
80 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
82 You can contact me by mail or on C<irc.perl.org> (vincent).
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.
91 You can find documentation for this module with the perldoc command.
95 =head1 COPYRIGHT & LICENSE
97 Copyright 2010 Vincent Pit, all rights reserved.
99 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
103 1; # End of LaTeX::TikZ::Mod::Pattern