1 package LaTeX::TikZ::Mod::Pattern::Dots;
8 LaTeX::TikZ::Mod::Pattern::Dots - A dotted pattern modifier.
16 our $VERSION = '0.02';
21 use Any::Moose 'Util::TypeConstraints';
25 This class inherits the L<LaTeX::TikZ::Mod::Pattern> class and its L<LaTeX::TikZ::Mod::Pattern/tag>, L<LaTeX::TikZ::Mod::Pattern/covers>, L<LaTeX::TikZ::Mod::Pattern/declare> and L<LaTeX::TikZ::Mod::Pattern/apply> methods.
29 extends 'LaTeX::TikZ::Mod::Pattern';
39 isa => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) >= 0 }),
47 has 'space_width' => (
49 isa => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) >= 0 }),
53 my $W = Sub::Name::subname('WIDTH' => sub { sprintf '#WIDTH=%0.1f#', @_ });
55 my $forge_template = Sub::Name::subname('forge_template' => sub {
56 my ($dot_width, $space_width) = @_;
58 my ($low_left, $up_right, $tile_size, $center);
59 my ($width, $half_width, $shadow_min, $shadow_max);
61 $width = $W->($space_width);
62 $half_width = $W->($space_width / 2);
64 $shadow_min = $W->(- $dot_width);
65 $shadow_max = $W->($space_width + $dot_width);
66 $dot_width = $W->($dot_width);
68 $low_left = "\\pgfqpoint{$shadow_min}{$shadow_min}";
69 $up_right = "\\pgfqpoint{$shadow_max}{$shadow_max}";
70 $center = "\\pgfqpoint{$half_width}{$half_width}";
71 $tile_size = "\\pgfqpoint{$width}{$width}";
74 "\\pgfdeclarepatternformonly{#NAME#}{$low_left}{$up_right}{$tile_size}{",
75 "\\pgfpathcircle{$center}{$dot_width}",
81 around 'BUILDARGS' => sub {
82 my ($orig, $class, %args) = @_;
84 confess('Can\'t specify an explicit template for a '. __PACKAGE__ .' pattern')
85 if exists $args{template};
87 my @params = qw<dot_width space_width>;
89 my $meta = $class->meta;
91 my $attr = $meta->find_attribute_by_name($_);
92 $args{$_} = $attr->default if $attr->has_default and not exists $args{$_};
93 $attr->type_constraint->assert_valid($args{$_});
96 $args{template} = $forge_template->(@args{@params});
101 __PACKAGE__->meta->make_immutable;
105 L<LaTeX::TikZ>, L<LaTeX::TikZ::Mod::Pattern>.
109 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
111 You can contact me by mail or on C<irc.perl.org> (vincent).
115 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>.
116 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
120 You can find documentation for this module with the perldoc command.
124 =head1 COPYRIGHT & LICENSE
126 Copyright 2010 Vincent Pit, all rights reserved.
128 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
132 1; # End of LaTeX::TikZ::Mod::Pattern::Dots