lib/LaTeX/TikZ/Mod/Pattern/Dots.pm
lib/LaTeX/TikZ/Mod/Pattern/Lines.pm
lib/LaTeX/TikZ/Mod/Raw.pm
+lib/LaTeX/TikZ/Mod/Scale.pm
lib/LaTeX/TikZ/Mod/Width.pm
lib/LaTeX/TikZ/Point.pm
lib/LaTeX/TikZ/Point/Math/Complex.pm
->mod(Tikz->pattern(class => 'Dots'))
->layer('top');
+=head3 C<< Tikz->scale($factor) >>
+
+Creates a L<LaTeX::TikZ::Mod::Scale> object that scales the sets onto which it apply by the given C<$factor>.
+
+ my $circle_of_radius_2 = Tikz->circle(0 => 1)
+ ->mod(Tikz->scale(2));
+
=head3 C<< Tikz->width($line_width) >>
Creates a L<LaTeX::TikZ::Mod::Width> object that sets the line width to C<$line_width> when applied.
require LaTeX::TikZ::Mod::Clip; # clip
require LaTeX::TikZ::Mod::Layer; # layer
+ require LaTeX::TikZ::Mod::Scale; # scale
require LaTeX::TikZ::Mod::Width; # width
require LaTeX::TikZ::Mod::Color; # color
require LaTeX::TikZ::Mod::Fill; # fill
--- /dev/null
+package LaTeX::TikZ::Mod::Scale;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+LaTeX::TikZ::Mod::Scale - A modifier that scales a TikZ set tree.
+
+=head1 VERSION
+
+Version 0.02
+
+=cut
+
+our $VERSION = '0.02';
+
+use LaTeX::TikZ::Interface;
+
+use LaTeX::TikZ::Tools;
+
+use Any::Moose;
+
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Mod> role, and as such implements the L</tag>, L</covers>, L</declare> and L</apply> methods.
+
+=cut
+
+with 'LaTeX::TikZ::Mod';
+
+=head1 ATTRIBUTES
+
+=head2 C<scale>
+
+=cut
+
+has 'scale' => (
+ is => 'ro',
+ isa => 'Num',
+ required => 1,
+);
+
+=head1 METHODS
+
+=head2 C<tag>
+
+=cut
+
+sub tag { ref $_[0] }
+
+=head2 C<covers>
+
+=cut
+
+sub covers { LaTeX::TikZ::Tools::numeq($_[0]->scale, $_[1]->scale) }
+
+=head2 C<declare>
+
+=cut
+
+sub declare { }
+
+=head2 C<apply>
+
+=cut
+
+sub apply { sprintf 'scale=%0.3f', $_[0]->scale }
+
+LaTeX::TikZ::Interface->register(
+ scale => sub {
+ shift;
+
+ __PACKAGE__->new(scale => $_[0]);
+ },
+);
+
+__PACKAGE__->meta->make_immutable;
+
+=head1 SEE ALSO
+
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Mod>.
+
+=head1 AUTHOR
+
+Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
+
+You can contact me by mail or on C<irc.perl.org> (vincent).
+
+=head1 BUGS
+
+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>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc LaTeX::TikZ
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2011 Vincent Pit, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1; # End of LaTeX::TikZ::Mod::Scale
use strict;
use warnings;
-use Test::More tests => 35;
+use Test::More tests => 36;
BEGIN {
use_ok( 'LaTeX::TikZ' );
use_ok( 'LaTeX::TikZ::Mod::Pattern::Dots' );
use_ok( 'LaTeX::TikZ::Mod::Pattern::Lines' );
use_ok( 'LaTeX::TikZ::Mod::Raw' );
+ use_ok( 'LaTeX::TikZ::Mod::Scale' );
use_ok( 'LaTeX::TikZ::Mod::Width' );
use_ok( 'LaTeX::TikZ::Point' );
use_ok( 'LaTeX::TikZ::Point::Math::Complex' );
use strict;
use warnings;
-use Test::More tests => 5 + 22 + 12;
+use Test::More tests => 5 + 23 + 12;
use LaTeX::TikZ;
point line polyline closed_polyline rectangle circle arc arrow
raw_mod
clip layer
- width color fill pattern
+ scale width color fill pattern
>;
for (@methods) {
use strict;
use warnings;
-use Test::More tests => 20 + 2 * 22;
+use Test::More tests => 23 + 2 * 24;
use LaTeX::TikZ;
};
like $@, failed_valid('LaTeX::TikZ::Mod'), 'trying to use a non LTM mod croaks';
+my $scale = eval {
+ Tikz->scale(2);
+};
+is $@, '', 'creating a scale mod doesn\'t croak';
+
+$foo2 = eval {
+ Tikz->raw('foo')
+ ->mod($scale);
+};
+is $@, '', 'applying a scale mod doesn\'t croak';
+
+check $foo2, 'a raw set with a scale mod', <<'RES';
+\draw [scale=2.000] foo ;
+RES
+
+$foo2 = eval {
+ Tikz->union(
+ Tikz->raw('foo')
+ ->mod($scale),
+ )->mod(Tikz->scale(4));
+};
+is $@, '', 'applying two scale mods doesn\'t croak';
+
+check $foo2, 'a union of a raw set with two scale mods', <<'RES';
+\draw [scale=4.000] foo ;
+RES
+
my $width = eval {
Tikz->width(25);
};
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@;
-plan tests => 35;
+plan tests => 36;
my $moose_private = { also_private => [ qr/^BUILD$/, qr/^DEMOLISH$/ ] };
pod_coverage_ok( 'LaTeX::TikZ::Mod::Pattern::Dots' );
pod_coverage_ok( 'LaTeX::TikZ::Mod::Pattern::Lines' );
pod_coverage_ok( 'LaTeX::TikZ::Mod::Raw' );
+pod_coverage_ok( 'LaTeX::TikZ::Mod::Scale' );
pod_coverage_ok( 'LaTeX::TikZ::Mod::Width' );
pod_coverage_ok( 'LaTeX::TikZ::Point' );
pod_coverage_ok( 'LaTeX::TikZ::Point::Math::Complex' );