]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Mod/Pattern/Lines.pm
Enforce the non-negativity of some attributes with anonymous types
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Mod / Pattern / Lines.pm
index 494817a0b41edc97dccb4c0bc6bd634e616878a8..a86844020ded2e165e087dea465d31adf8fe87f5 100644 (file)
@@ -36,13 +36,13 @@ has 'direction' => (
 
 has 'line_width' => (
  is      => 'ro',
- isa     => 'Int',
+ isa     => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) >= 0 }),
  default => 1,
 );
 
 has 'space_width' => (
  is      => 'ro',
- isa     => 'Int',
+ isa     => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) >= 0 }),
  default => 1,
 );
 
@@ -89,18 +89,18 @@ my $forge_template = Sub::Name::subname('forge_template' => sub {
   return;
  }
 
- <<" PATTERN";
-\\pgfdeclarepatternformonly{#NAME#}{$low_left}{$up_right}{$tile_size}{%
- \\pgfsetlinewidth{$line_width}
- \\pgfpathmoveto{$line_begin}
- \\pgfpathlineto{$line_end}
- \\pgfusepath{stroke}
-}
- PATTERN
+ return [
+  "\\pgfdeclarepatternformonly{#NAME#}{$low_left}{$up_right}{$tile_size}{",
+  "\\pgfsetlinewidth{$line_width}",
+  "\\pgfpathmoveto{$line_begin}",
+  "\\pgfpathlineto{$line_end}",
+  "\\pgfusepath{stroke}",
+  "}",
+ ];
 });
 
 around 'BUILDARGS' => sub {
- my ($orig, $class, %args);
+ my ($orig, $class, %args) = @_;
 
  confess('Can\'t specify an explicit template for a '. __PACKAGE__ .' pattern')
                                                       if exists $args{template};