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';
24 isa => 'ArrayRef[Str]',
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;
62 $cache = $pat->_cache->{$tikz_id} = [ ];
63 $cache->[0] = 'pat' . $id++;
65 my $template = [ map $_, @{$pat->template} ];
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;
76 sub apply { 'fill', 'pattern=' . $_[0]->name($_[1]) }
78 use LaTeX::TikZ::Interface pattern => sub {
82 if (exists $args{class}) {
83 $class = delete $args{class};
84 $class = __PACKAGE__ . '::' . $class unless $class =~ /::/;
85 (my $pm = $class) =~ s{::}{/}g;
93 __PACKAGE__->meta->make_immutable;
97 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
99 You can contact me by mail or on C<irc.perl.org> (vincent).
103 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>.
104 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
108 You can find documentation for this module with the perldoc command.
112 =head1 COPYRIGHT & LICENSE
114 Copyright 2010 Vincent Pit, all rights reserved.
116 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
120 1; # End of LaTeX::TikZ::Mod::Pattern