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';
18 use LaTeX::TikZ::Interface;
22 with 'LaTeX::TikZ::Mod';
26 isa => 'ArrayRef[Str]',
34 default => sub { +{ } },
38 my ($pat, $tikz) = @_;
40 my $cache = $pat->_cache->{$tikz->id};
41 confess('Template not yet declared') unless defined $cache;
49 name => sub { $_[0]->name($_[1]) },
50 width => sub { sprintf '%0.1fpt', $_[1]->thickness($_[2]) },
58 my ($pat, $tikz) = @_;
60 my $tikz_id = $tikz->id;
61 my $cache = $pat->_cache->{$tikz_id};
62 return @{$cache->[1]} if defined $cache;
64 $cache = $pat->_cache->{$tikz_id} = [ ];
65 $cache->[0] = 'pat' . $id++;
67 my $template = [ map $_, @{$pat->template} ];
69 my ($command, @opts) = split /=/, $1, 2;
70 @opts = split /,/, $opts[0] if @opts;
71 $handlers{lc $command}->($pat, $tikz, @opts);
73 $cache->[1] = $template;
78 sub apply { 'fill', 'pattern=' . $_[0]->name($_[1]) }
80 LaTeX::TikZ::Interface->register(
85 if (exists $args{class}) {
86 $class = delete $args{class};
87 $class = __PACKAGE__ . '::' . $class unless $class =~ /::/;
88 (my $pm = $class) =~ s{::}{/}g;
97 __PACKAGE__->meta->make_immutable;
101 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
103 You can contact me by mail or on C<irc.perl.org> (vincent).
107 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>.
108 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
112 You can find documentation for this module with the perldoc command.
116 =head1 COPYRIGHT & LICENSE
118 Copyright 2010 Vincent Pit, all rights reserved.
120 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
124 1; # End of LaTeX::TikZ::Mod::Pattern