1 package LaTeX::TikZ::Mod::Pattern::Dots;
8 LaTeX::TikZ::Mod::Pattern::Dots - A dotted pattern modifier.
16 our $VERSION = '0.01';
22 extends 'LaTeX::TikZ::Mod::Pattern';
30 has 'space_width' => (
36 my $W = Sub::Name::subname('WIDTH' => sub { sprintf '#WIDTH=%0.1f#', @_ });
38 my $forge_template = Sub::Name::subname('forge_template' => sub {
39 my ($dot_width, $space_width) = @_;
41 my ($low_left, $up_right, $tile_size, $center);
42 my ($width, $half_width, $shadow_min, $shadow_max);
44 $width = $W->($space_width);
45 $half_width = $W->($space_width / 2);
47 $shadow_min = $W->(- $dot_width);
48 $shadow_max = $W->($space_width + $dot_width);
49 $dot_width = $W->($dot_width);
51 $low_left = "\\pgfqpoint{$shadow_min}{$shadow_min}";
52 $up_right = "\\pgfqpoint{$shadow_max}{$shadow_max}";
53 $center = "\\pgfqpoint{$half_width}{$half_width}";
54 $tile_size = "\\pgfqpoint{$width}{$width}";
57 \\pgfdeclarepatternformonly{#NAME#}{$low_left}{$up_right}{$tile_size}{%
58 \\pgfpathcircle{$center}{$dot_width}
64 around 'BUILDARGS' => sub {
65 my ($orig, $class, %args);
67 confess('Can\'t specify an explicit template for a '. __PACKAGE__ .' pattern')
68 if exists $args{template};
70 my @params = qw/dot_width space_width/;
72 my $meta = $class->meta;
74 my $attr = $meta->find_attribute_by_name($_);
75 $args{$_} = $attr->default if $attr->has_default and not exists $args{$_};
76 $attr->type_constraint->assert_valid($args{$_});
79 $args{template} = $forge_template->(@args{@params});
84 __PACKAGE__->meta->make_immutable;
88 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
90 You can contact me by mail or on C<irc.perl.org> (vincent).
94 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>.
95 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
99 You can find documentation for this module with the perldoc command.
103 =head1 COPYRIGHT & LICENSE
105 Copyright 2010 Vincent Pit, all rights reserved.
107 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
111 1; # End of LaTeX::TikZ::Mod::Pattern::Dots