]> git.imager.perl.org - imager.git/commitdiff
prevent warnings/errors under 5.004_04
authorTony Cook <tony@develop=help.com>
Tue, 30 Oct 2001 01:19:54 +0000 (01:19 +0000)
committerTony Cook <tony@develop=help.com>
Tue, 30 Oct 2001 01:19:54 +0000 (01:19 +0000)
14 files changed:
Imager.pm
lib/Imager/Color.pm
lib/Imager/Fill.pm
lib/Imager/Font.pm
lib/Imager/Font/FreeType2.pm
lib/Imager/Font/Truetype.pm
lib/Imager/Font/Type1.pm
lib/Imager/Matrix2d.pm
lib/Imager/Transform.pm
t/t105gif.t
t/t16matrix.t
t/t20fill.t
t/t37w32font.t
t/t38ft2font.t

index 0e960cf2eac0eff81467dd5f67188491bd13fc1f..704c3ebbfe21b66dca8d89ae6ed607e654b57737 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -321,7 +321,7 @@ BEGIN {
                               multiply  => 2, mult => 2,
                               dissolve  => 3,
                               add       => 4,
-                              subtract  => 5, sub => 5,
+                              subtract  => 5, 'sub' => 5,
                               diff      => 6,
                               lighten   => 7,
                               darken    => 8,
@@ -794,8 +794,8 @@ sub deltag {
 
   return 0 unless $self->{IMG};
 
-  if (defined $opts{index}) {
-    return i_tags_delete($self->{IMG}, $opts{index});
+  if (defined $opts{'index'}) {
+    return i_tags_delete($self->{IMG}, $opts{'index'});
   }
   elsif (defined $opts{name}) {
     return i_tags_delbyname($self->{IMG}, $opts{name});
@@ -844,20 +844,20 @@ sub read {
   # has been there for half a year dude.
   # Look, i just work here, ok?
 
-  if (!$input{type} and $input{file}) {
-    $input{type}=$FORMATGUESS->($input{file});
+  if (!$input{'type'} and $input{file}) {
+    $input{'type'}=$FORMATGUESS->($input{file});
   }
-  if (!$formats{$input{type}}) {
+  if (!$formats{$input{'type'}}) {
     $self->{ERRSTR}='format not supported'; return undef;
   }
 
   my %iolready=(jpeg=>1, png=>1, tiff=>1, pnm=>1, raw=>1, bmp=>1, tga=>1);
 
-  if ($iolready{$input{type}}) {
+  if ($iolready{$input{'type'}}) {
     # Setup data source
     $IO = io_new_fd($fd);      # sort of simple for now eh?
 
-    if ( $input{type} eq 'jpeg' ) {
+    if ( $input{'type'} eq 'jpeg' ) {
       ($self->{IMG},$self->{IPTCRAW})=i_readjpeg_wiol( $IO );
       if ( !defined($self->{IMG}) ) {
        $self->{ERRSTR}='unable to read jpeg image'; return undef;
@@ -866,7 +866,7 @@ sub read {
       return $self;
     }
 
-    if ( $input{type} eq 'tiff' ) {
+    if ( $input{'type'} eq 'tiff' ) {
       $self->{IMG}=i_readtiff_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
       if ( !defined($self->{IMG}) ) {
        $self->{ERRSTR}='unable to read tiff image'; return undef;
@@ -875,7 +875,7 @@ sub read {
       return $self;
     }
 
-    if ( $input{type} eq 'pnm' ) {
+    if ( $input{'type'} eq 'pnm' ) {
       $self->{IMG}=i_readpnm_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
       if ( !defined($self->{IMG}) ) {
        $self->{ERRSTR}='unable to read pnm image: '._error_as_msg(); return undef;
@@ -884,7 +884,7 @@ sub read {
       return $self;
     }
 
-    if ( $input{type} eq 'png' ) {
+    if ( $input{'type'} eq 'png' ) {
       $self->{IMG}=i_readpng_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
       if ( !defined($self->{IMG}) ) {
        $self->{ERRSTR}='unable to read png image';
@@ -893,7 +893,7 @@ sub read {
       $self->{DEBUG} && print "loading a png file\n";
     }
 
-    if ( $input{type} eq 'bmp' ) {
+    if ( $input{'type'} eq 'bmp' ) {
       $self->{IMG}=i_readbmp_wiol( $IO );
       if ( !defined($self->{IMG}) ) {
        $self->{ERRSTR}='unable to read bmp image';
@@ -902,7 +902,7 @@ sub read {
       $self->{DEBUG} && print "loading a bmp file\n";
     }
 
-    if ( $input{type} eq 'tga' ) {
+    if ( $input{'type'} eq 'tga' ) {
       $self->{IMG}=i_readtga_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
       if ( !defined($self->{IMG}) ) {
        $self->{ERRSTR}=$self->_error_as_msg();
@@ -912,7 +912,7 @@ sub read {
       $self->{DEBUG} && print "loading a tga file\n";
     }
 
-    if ( $input{type} eq 'raw' ) {
+    if ( $input{'type'} eq 'raw' ) {
       my %params=(datachannels=>3,storechannels=>3,interleave=>1,%input);
 
       if ( !($params{xsize} && $params{ysize}) ) {
@@ -937,15 +937,15 @@ sub read {
 
     # Old code for reference while changing the new stuff
 
-    if (!$input{type} and $input{file}) {
-      $input{type}=$FORMATGUESS->($input{file});
+    if (!$input{'type'} and $input{file}) {
+      $input{'type'}=$FORMATGUESS->($input{file});
     }
 
-    if (!$input{type}) {
+    if (!$input{'type'}) {
       $self->{ERRSTR}='type parameter missing and not possible to guess from extension'; return undef;
     }
 
-    if (!$formats{$input{type}}) {
+    if (!$formats{$input{'type'}}) {
       $self->{ERRSTR}='format not supported';
       return undef;
     }
@@ -964,7 +964,7 @@ sub read {
       $fd=$input{fd};
     }
 
-    if ( $input{type} eq 'gif' ) {
+    if ( $input{'type'} eq 'gif' ) {
       my $colors;
       if ($input{colors} && !ref($input{colors})) {
        # must be a reference to a scalar that accepts the colour map
@@ -1016,10 +1016,15 @@ sub write {
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
 
   if (!$input{file} and !$input{'fd'} and !$input{'data'}) { $self->{ERRSTR}='file/fd/data parameter missing'; return undef; }
-  if (!$input{type} and $input{file}) { $input{type}=$FORMATGUESS->($input{file}); }
-  if (!$input{type}) { $self->{ERRSTR}='type parameter missing and not possible to guess from extension'; return undef; }
+  if (!$input{'type'} and $input{file}) { 
+    $input{'type'}=$FORMATGUESS->($input{file});
+  }
+  if (!$input{'type'}) { 
+    $self->{ERRSTR}='type parameter missing and not possible to guess from extension';
+    return undef;
+  }
 
-  if (!$formats{$input{type}}) { $self->{ERRSTR}='format not supported'; return undef; }
+  if (!$formats{$input{'type'}}) { $self->{ERRSTR}='format not supported'; return undef; }
 
   if (exists $input{'fd'}) {
     $fd=$input{'fd'};
@@ -1032,12 +1037,12 @@ sub write {
     $fd = $fh->fileno();
   }
 
-  if ($iolready{$input{type}}) {
+  if ($iolready{$input{'type'}}) {
     if (defined $fd) {
       $IO = io_new_fd($fd);
     }
 
-    if ($input{type} eq 'tiff') {
+    if ($input{'type'} eq 'tiff') {
       if (defined $input{class} && $input{class} eq 'fax') {
        if (!i_writetiff_wiol_faxable($self->{IMG}, $IO, $input{fax_fine})) {
          $self->{ERRSTR}='Could not write to buffer';
@@ -1049,37 +1054,37 @@ sub write {
          return undef;
        }
       }
-    } elsif ( $input{type} eq 'pnm' ) {
+    } elsif ( $input{'type'} eq 'pnm' ) {
       if ( ! i_writeppm_wiol($self->{IMG},$IO) ) {
        $self->{ERRSTR}='unable to write pnm image';
        return undef;
       }
       $self->{DEBUG} && print "writing a pnm file\n";
-    } elsif ( $input{type} eq 'raw' ) {
+    } elsif ( $input{'type'} eq 'raw' ) {
       if ( !i_writeraw_wiol($self->{IMG},$IO) ) {
        $self->{ERRSTR}='unable to write raw image';
        return undef;
       }
       $self->{DEBUG} && print "writing a raw file\n";
-    } elsif ( $input{type} eq 'png' ) {
+    } elsif ( $input{'type'} eq 'png' ) {
       if ( !i_writepng_wiol($self->{IMG}, $IO) ) {
        $self->{ERRSTR}='unable to write png image';
        return undef;
       }
       $self->{DEBUG} && print "writing a png file\n";
-    } elsif ( $input{type} eq 'jpeg' ) {
+    } elsif ( $input{'type'} eq 'jpeg' ) {
       if ( !i_writejpeg_wiol($self->{IMG}, $IO, $input{jpegquality})) {
         $self->{ERRSTR} = $self->_error_as_msg();
        return undef;
       }
       $self->{DEBUG} && print "writing a jpeg file\n";
-    } elsif ( $input{type} eq 'bmp' ) {
+    } elsif ( $input{'type'} eq 'bmp' ) {
       if ( !i_writebmp_wiol($self->{IMG}, $IO) ) {
        $self->{ERRSTR}='unable to write bmp image';
        return undef;
       }
       $self->{DEBUG} && print "writing a bmp file\n";
-    } elsif ( $input{type} eq 'tga' ) {
+    } elsif ( $input{'type'} eq 'tga' ) {
 
       if ( !i_writetga_wiol($self->{IMG}, $IO, $input{wierdpack}, $input{compress}, $input{idstring}) ) {
        $self->{ERRSTR}=$self->_error_as_msg();
@@ -1098,7 +1103,7 @@ sub write {
     }
     return $self;
   } else {
-    if ( $input{type} eq 'gif' ) {
+    if ( $input{'type'} eq 'gif' ) {
       if (not $input{gifplanes}) {
        my $gp;
        my $count=i_count_colors($self->{IMG}, 256);
@@ -1157,7 +1162,7 @@ sub write {
 sub write_multi {
   my ($class, $opts, @images) = @_;
 
-  if ($opts->{type} eq 'gif') {
+  if ($opts->{'type'} eq 'gif') {
     my $gif_delays = $opts->{gif_delays};
     local $opts->{gif_delays} = $gif_delays;
     unless (ref $opts->{gif_delays}) {
@@ -1191,7 +1196,7 @@ sub write_multi {
     }
   }
   else {
-    $ERRSTR = "Sorry, write_multi doesn't support $opts->{type} yet";
+    $ERRSTR = "Sorry, write_multi doesn't support $opts->{'type'} yet";
     return 0;
   }
 }
@@ -1200,12 +1205,12 @@ sub write_multi {
 sub read_multi {
   my ($class, %opts) = @_;
 
-  if ($opts{file} && !exists $opts{type}) {
+  if ($opts{file} && !exists $opts{'type'}) {
     # guess the type 
     my $type = $FORMATGUESS->($opts{file});
-    $opts{type} = $type;
+    $opts{'type'} = $type;
   }
-  unless ($opts{type}) {
+  unless ($opts{'type'}) {
     $ERRSTR = "No type parameter supplied and it couldn't be guessed";
     return;
   }
@@ -1238,7 +1243,7 @@ sub read_multi {
     return;
   }
 
-  if ($opts{type} eq 'gif') {
+  if ($opts{'type'} eq 'gif') {
     my @imgs;
     if ($fd) {
       @imgs = i_readgif_multi($fd);
@@ -1266,7 +1271,7 @@ sub read_multi {
     }
   }
 
-  $ERRSTR = "Cannot read multiple images from $opts{type} files";
+  $ERRSTR = "Cannot read multiple images from $opts{'type'} files";
   return;
 }
 
@@ -1296,35 +1301,35 @@ sub filter {
   my %hsh;
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
 
-  if (!$input{type}) { $self->{ERRSTR}='type parameter missing'; return undef; }
+  if (!$input{'type'}) { $self->{ERRSTR}='type parameter missing'; return undef; }
 
-  if ( (grep { $_ eq $input{type} } keys %filters) != 1) {
+  if ( (grep { $_ eq $input{'type'} } keys %filters) != 1) {
     $self->{ERRSTR}='type parameter not matching any filter'; return undef;
   }
 
-  if ($filters{$input{type}}{names}) {
-    my $names = $filters{$input{type}}{names};
+  if ($filters{$input{'type'}}{names}) {
+    my $names = $filters{$input{'type'}}{names};
     for my $name (keys %$names) {
       if (defined $input{$name} && exists $names->{$name}{$input{$name}}) {
         $input{$name} = $names->{$name}{$input{$name}};
       }
     }
   }
-  if (defined($filters{$input{type}}{defaults})) {
-    %hsh=('image',$self->{IMG},%{$filters{$input{type}}{defaults}},%input);
+  if (defined($filters{$input{'type'}}{defaults})) {
+    %hsh=('image',$self->{IMG},%{$filters{$input{'type'}}{defaults}},%input);
   } else {
     %hsh=('image',$self->{IMG},%input);
   }
 
-  my @cs=@{$filters{$input{type}}{callseq}};
+  my @cs=@{$filters{$input{'type'}}{callseq}};
 
   for(@cs) {
     if (!defined($hsh{$_})) {
-      $self->{ERRSTR}="missing parameter '$_' for filter ".$input{type}; return undef;
+      $self->{ERRSTR}="missing parameter '$_' for filter ".$input{'type'}; return undef;
     }
   }
 
-  &{$filters{$input{type}}{callsub}}(%hsh);
+  &{$filters{$input{'type'}}{callsub}}(%hsh);
 
   my @b=keys %hsh;
 
@@ -1338,16 +1343,16 @@ sub filter {
 
 sub scale {
   my $self=shift;
-  my %opts=(scalefactor=>0.5,type=>'max',qtype=>'normal',@_);
+  my %opts=(scalefactor=>0.5,'type'=>'max',qtype=>'normal',@_);
   my $img = Imager->new();
   my $tmp = Imager->new();
 
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
 
-  if ($opts{xpixels} and $opts{ypixels} and $opts{type}) {
+  if ($opts{xpixels} and $opts{ypixels} and $opts{'type'}) {
     my ($xpix,$ypix)=( $opts{xpixels}/$self->getwidth() , $opts{ypixels}/$self->getheight() );
-    if ($opts{type} eq 'min') { $opts{scalefactor}=min($xpix,$ypix); }
-    if ($opts{type} eq 'max') { $opts{scalefactor}=max($xpix,$ypix); }
+    if ($opts{'type'} eq 'min') { $opts{scalefactor}=min($xpix,$ypix); }
+    if ($opts{'type'} eq 'max') { $opts{scalefactor}=max($xpix,$ypix); }
   } elsif ($opts{xpixels}) { $opts{scalefactor}=$opts{xpixels}/$self->getwidth(); }
   elsif ($opts{ypixels}) { $opts{scalefactor}=$opts{ypixels}/$self->getheight(); }
 
@@ -1431,9 +1436,9 @@ sub transform {
                                             {op=>'-',trans=>'Sub'},
                                             {op=>'*',trans=>'Mult'},
                                             {op=>'/',trans=>'Div'},
-                                            {op=>'-',type=>'unary',trans=>'u-'},
+                                            {op=>'-','type'=>'unary',trans=>'u-'},
                                             {op=>'**'},
-                                            {op=>'func',type=>'unary'}],
+                                            {op=>'func','type'=>'unary'}],
                                     'grouping'=>[qw( \( \) )],
                                     'func'=>[qw( sin cos )],
                                     'vars'=>[qw( x y )]
@@ -1817,7 +1822,7 @@ sub flood_fill {
   my $self = shift;
   my %opts = ( color=>Imager::Color->new(255, 255, 255), @_ );
 
-  unless (exists $opts{x} && exists $opts{'y'}) {
+  unless (exists $opts{'x'} && exists $opts{'y'}) {
     $self->{ERRSTR} = "missing seed x and y parameters";
     return undef;
   }
@@ -1831,10 +1836,10 @@ sub flood_fill {
         return;
       }
     }
-    i_flood_cfill($self->{IMG}, $opts{x}, $opts{'y'}, $opts{fill}{fill});
+    i_flood_cfill($self->{IMG}, $opts{'x'}, $opts{'y'}, $opts{fill}{fill});
   }
   else {
-    i_flood_fill($self->{IMG}, $opts{x}, $opts{'y'}, $opts{color});
+    i_flood_fill($self->{IMG}, $opts{'x'}, $opts{'y'}, $opts{color});
   }
 
   $self;
@@ -2029,7 +2034,7 @@ sub setmask {
 
 sub getcolorcount {
   my $self=shift;
-  my %opts=(maxcolors=>2**30,@_);
+  my %opts=('maxcolors'=>2**30,@_);
   if (!defined($self->{IMG})) { $self->{ERRSTR}='image is empty'; return undef; }
   my $rc=i_count_colors($self->{IMG},$opts{'maxcolors'});
   return ($rc==-1? undef : $rc);
index 522aa2d0026ef41e939c92d00694dfc9e160710e..336736f9284dd0357492abade55cbfaa2d7fd032 100644 (file)
@@ -36,7 +36,7 @@ sub _hsv_to_rgb {
     my $n = $val * (1.0 - $sat * $f);
     my $k = $val * (1.0 - $sat * (1 - $f));
     my $v = $val;
-    my %fields = ( m=>$m, n=>$n, v=>$v, k=>$k, );
+    my %fields = ( 'm'=>$m, 'n'=>$n, 'v'=>$v, 'k'=>$k, );
     return @fields{split //, $hsv_map[$i]};
   }
 }
index 037f0d6f35b507312b9ea87ccf81b1bfad567bee..dc50c590bad7f2059069d43ba3326309b8203585 100644 (file)
@@ -16,7 +16,7 @@ my @combine_types =
 my %combine_types;
 @combine_types{@combine_types} = 0 .. $#combine_types;
 $combine_types{mult} = $combine_types{multiply};
-$combine_types{sub}  = $combine_types{subtract};
+$combine_types{'sub'}  = $combine_types{subtract};
 $combine_types{sat}  = $combine_types{saturation};
 
 # this function tries to DWIM for color parameters
index 92742184cf0202bc9ec6f7569156a3fe91f4fa74..262b742104b9396100650cd16997e06993788102 100644 (file)
@@ -1,9 +1,7 @@
-
 package Imager::Font;
 
 use Imager::Color;
 use strict;
-use File::Spec;
 
 # the aim here is that we can:
 #  - add file based types in one place: here
@@ -112,7 +110,7 @@ sub _first {
 
 sub draw {
   my $self = shift;
-  my %input = (x => 0, 'y' => 0, @_);
+  my %input = ('x' => 0, 'y' => 0, @_);
   unless ($input{image}) {
     $Imager::ERRSTR = 'No image supplied to $font->draw()';
     return;
index 1f1a7746f9177d8216c4f3910a8e40d62ce71509..1e1461bb17ab5db9397d4c9575907a385449f0ca 100644 (file)
@@ -21,7 +21,7 @@ sub new {
     $Imager::ERRSTR = "Freetype2 not supported in this build";
     return;
   }
-  my $id = i_ft2_new($hsh{file}, $hsh{index} || 0);
+  my $id = i_ft2_new($hsh{file}, $hsh{'index'} || 0);
   unless ($id) { # the low-level code may miss some error handling
     $Imager::ERRSTR = Imager::_error_as_msg();
     return;
@@ -42,13 +42,13 @@ sub _draw {
   my $self = shift;
   my %input = @_;
   if (exists $input{channel}) {
-    i_ft2_cp($self->{id}, $input{image}{IMG}, $input{x}, $input{'y'},
+    i_ft2_cp($self->{id}, $input{image}{IMG}, $input{'x'}, $input{'y'},
              $input{channel}, $input{size}, $input{sizew} || 0,
              $input{string}, , $input{align}, $input{aa}, $input{vlayout},
              $input{utf8});
   } else {
     i_ft2_text($self->{id}, $input{image}{IMG}, 
-               $input{x}, $input{'y'}, 
+               $input{'x'}, $input{'y'}, 
                $input{color}, $input{size}, $input{sizew} || 0,
                $input{string}, $input{align}, $input{aa}, $input{vlayout},
                $input{utf8});
index 61d57280e93dd2b1562fb3a36903cb691afe7e1e..1080d3341ac73bdbf545bdb952a5d556eda12bc0 100644 (file)
@@ -41,11 +41,11 @@ sub _draw {
   my %input = @_;
   if ( exists $input{channel} ) {
     Imager::i_tt_cp($self->{id},$input{image}{IMG},
-                   $input{x}, $input{'y'}, $input{channel}, $input{size},
+                   $input{'x'}, $input{'y'}, $input{channel}, $input{size},
                    $input{string}, length($input{string}),$input{aa}); 
   } else {
     Imager::i_tt_text($self->{id}, $input{image}{IMG}, 
-                     $input{x}, $input{'y'}, $input{color},
+                     $input{'x'}, $input{'y'}, $input{color},
                      $input{size}, $input{string}, 
                      length($input{string}), $input{aa}); 
   }
index e3f884e39f22875ad11c3063b54c705ff4bfc5b0..cfb78f65bea8f7f83a82992b77a2d7389fa0f5d0 100644 (file)
@@ -3,7 +3,6 @@ use strict;
 use Imager::Color;
 use vars qw(@ISA);
 @ISA = qw(Imager::Font);
-use File::Spec;
 
 my $t1aa;
 
@@ -36,7 +35,7 @@ sub new {
     return;
   }
   unless ($hsh{file} =~ m!^/! || $hsh{file} =~ m!^\./!) {
-    $hsh{file} = File::Spec->catfile(File::Spec->curdir, $hsh{file});
+    $hsh{file} = './' . $hsh{file};
   }
   my $id = Imager::i_t1_new($hsh{file});
   unless ($id >= 0) { # the low-level code may miss some error handling
@@ -58,11 +57,11 @@ sub _draw {
   my %input = @_;
   t1_set_aa_level($input{aa});
   if (exists $input{channel}) {
-    Imager::i_t1_cp($input{image}{IMG}, $input{x}, $input{'y'},
+    Imager::i_t1_cp($input{image}{IMG}, $input{'x'}, $input{'y'},
                    $input{channel}, $self->{id}, $input{size},
                    $input{string}, length($input{string}), $input{align});
   } else {
-    Imager::i_t1_text($input{image}{IMG}, $input{x}, $input{'y'}, 
+    Imager::i_t1_text($input{image}{IMG}, $input{'x'}, $input{'y'}, 
                      $input{color}, $self->{id}, $input{size}, 
                      $input{string}, length($input{string}), 
                      $input{align});
index bab68c0695bdfbc34f0f98310ca10c32b65837a0..6917f18f3d6c9c84deb927fee427bcf514b7dc51 100644 (file)
@@ -91,10 +91,10 @@ sub rotate {
     return undef;
   }
 
-  if ($opts{x} && $opts{'y'}) {
-    return $class->translate(x=>-$opts{x}, 'y'=>-$opts{'y'})
+  if ($opts{'x'} && $opts{'y'}) {
+    return $class->translate('x'=>-$opts{'x'}, 'y'=>-$opts{'y'})
       * $class->rotate(radians=>$angle)
-        * $class->translate(x=>$opts{x}, 'y'=>$opts{'y'});
+        * $class->translate('x'=>$opts{'x'}, 'y'=>$opts{'y'});
   }
   else {
     my $sin = sin($angle);
@@ -113,8 +113,8 @@ Translates by the specify amounts.
 sub translate {
   my ($class, %opts) = @_;
 
-  if (defined $opts{x} && defined $opts{'y'}) {
-    return bless [ 1, 0, $opts{x},
+  if (defined $opts{'x'} && defined $opts{'y'}) {
+    return bless [ 1, 0, $opts{'x'},
                    0, 1, $opts{'y'},
                    0, 0, 1 ], $class;
   }
@@ -131,10 +131,10 @@ Shear by the given amounts.
 sub shear {
   my ($class, %opts) = @_;
 
-  if (defined $opts{x} || defined $opts{'y'}) {
-    return bless [ 1,             $opts{x}||0, 0,
-                   $opts{'y'}||0, 1,           0,
-                   0,             0,           1 ], $class;
+  if (defined $opts{'x'} || defined $opts{'y'}) {
+    return bless [ 1,             $opts{'x'}||0, 0,
+                   $opts{'y'}||0, 1,             0,
+                   0,             0,             1 ], $class;
   }
   $Imager::ERRSTR = 'x and y parameters required';
   return undef;
@@ -199,18 +199,18 @@ parameters.
 sub scale {
   my ($class, %opts) = @_;
 
-  if (defined $opts{x} || defined $opts{'y'}) {
-    $opts{x} = 1 unless defined $opts{x};
+  if (defined $opts{'x'} || defined $opts{'y'}) {
+    $opts{'x'} = 1 unless defined $opts{'x'};
     $opts{'y'} = 1 unless defined $opts{'y'};
     if ($opts{cx} || $opts{cy}) {
-      return $class->translate(x=>-$opts{cx}, 'y'=>-$opts{cy})
-        * $class->scale(x=>$opts{x}, 'y'=>$opts{'y'})
-          * $class->translate(x=>$opts{cx}, 'y'=>$opts{cy});
+      return $class->translate('x'=>-$opts{cx}, 'y'=>-$opts{cy})
+        * $class->scale('x'=>$opts{'x'}, 'y'=>$opts{'y'})
+          * $class->translate('x'=>$opts{cx}, 'y'=>$opts{cy});
     }
     else {
-      return bless [ $opts{x}, 0,          0,
-                     0,        $opts{'y'}, 0,
-                     0,        0,          1 ], $class;
+      return bless [ $opts{'x'}, 0,          0,
+                     0,          $opts{'y'}, 0,
+                     0,          0,          1 ], $class;
     }
   }
   else {
index 077c80579692df7bdc425eeea398030412e1678a..2d11034ad67796af4f81e0dbd9bb7415a8bfecbc 100644 (file)
@@ -357,10 +357,10 @@ sub transform {
   my %opts = %$opts;
   $opts{$func->{type}} = $func->{$func->{type}};
   my %con = %$constants;
-  for my $name (keys %{$func->{constants}}) {
+  for my $name (keys %{$func->{'constants'}}) {
     unless (exists $con{$name}) {
-      if (exists $func->{constants}{$name}{default}) {
-       $con{$name} = $func->{constants}{$name}{default};
+      if (exists $func->{'constants'}{$name}{default}) {
+       $con{$name} = $func->{'constants'}{$name}{default};
       }
       else {
        $self->{error} = "No value or default for constant $name";
@@ -368,10 +368,10 @@ sub transform {
       }
     }
   }
-  $opts{constants} = \%con;
-  unless (@in == @{$func->{inputs}}) {
+  $opts{'constants'} = \%con;
+  unless (@in == @{$func->{'inputs'}}) {
     $self->{error} = @in." input images given, ".
-      @{$func->{inputs}}." supplied";
+      @{$func->{'inputs'}}." supplied";
     return;
   }
 
@@ -407,21 +407,21 @@ sub describe {
 Function   : $name
 Description: $func->{desc}
 EOS
-  if ($func->{inputs} && @{$func->{inputs}}) {
+  if ($func->{'inputs'} && @{$func->{'inputs'}}) {
     $desc .= "Input images:\n";
     my $i = 1;
-    for my $in (@{$func->{inputs}}) {
+    for my $in (@{$func->{'inputs'}}) {
       $desc .= "  $i: $in->{desc}\n";
     }
   }
   else {
     $desc .= "There are no input images\n";
   }
-  if ($func->{constants} && keys %{$func->{constants}}) {
+  if ($func->{'constants'} && keys %{$func->{'constants'}}) {
     $desc .= "Input constants:\n";
-    for my $key (keys %{$func->{constants}}) {
-      $desc .= "  $key: $func->{constants}{$key}{desc}\n";
-      $desc .= "       Default: $func->{constants}{$key}{default}\n";
+    for my $key (keys %{$func->{'constants'}}) {
+      $desc .= "  $key: $func->{'constants'}{$key}{desc}\n";
+      $desc .= "       Default: $func->{'constants'}{$key}{default}\n";
     }
   }
   else {
index f206eac59abc06ff39c92b82034c9360bfca2263..0e026147b3ef247e6df9ec14fbced81b1d23ab5d 100644 (file)
@@ -405,19 +405,24 @@ EOS
       or print "not ";
     print "ok 34\n";
     close FH;
-    use Data::Dumper;
-    # build a big map of all tags for all images
-    @tags = 
-      map { 
-        my $im = $_; 
-        [ 
-         map { join ",", map { defined() ? $_ : "undef" } Imager::i_tags_get($im, $_) } 
-         0..Imager::i_tags_count($_)-1 
-        ] 
-      } @imgs;
-    my $dump = Dumper(\@tags);
-    $dump =~ s/^/# /mg;
-    print "# tags from gif\n", $dump;
+    eval {
+      require 'Data/Dumper.pm';
+      Data::Dumper->import();
+    };
+    unless ($@) {
+      # build a big map of all tags for all images
+      @tags = 
+       map { 
+         my $im = $_; 
+         [ 
+          map { join ",", map { defined() ? $_ : "undef" } Imager::i_tags_get($im, $_) } 
+          0..Imager::i_tags_count($_)-1 
+         ] 
+       } @imgs;
+      my $dump = Dumper(\@tags);
+      $dump =~ s/^/# /mg;
+      print "# tags from gif\n", $dump;
+    }
 
     # at this point @imgs should contain only paletted images
     ok(35, Imager::i_img_type($imgs[0]) == 1, "imgs[0] not paletted");
index f9b77db25f75e7b0da53f664be6fa89f3f2925ca..9a2760302ef3fb0c522eb943b4df59ff830f352a 100644 (file)
@@ -14,7 +14,7 @@ almost_equal($id, [ 1, 0, 0,
                     0, 1, 0,
                     0, 0, 1 ]) or print "not ";
 print "ok 2\n";
-my $trans = Imager::Matrix2d->translate(x=>10, 'y'=>-11);
+my $trans = Imager::Matrix2d->translate('x'=>10, 'y'=>-11);
 almost_equal($trans, [ 1, 0, 10,
                        0, 1, -11,
                        0, 0, 1 ]) or print "not ";
@@ -25,13 +25,13 @@ almost_equal($rotate, [ 0, -1, 0,
                         0, 0,  1 ]) or print "not ";
 print "ok 4\n";
 
-my $shear = Imager::Matrix2d->shear(x=>0.2, 'y'=>0.3);
+my $shear = Imager::Matrix2d->shear('x'=>0.2, 'y'=>0.3);
 almost_equal($shear, [ 1,   0.2, 0,
                        0.3, 1,   0,
                        0,   0,   1 ]) or print "not ";
 print "ok 5\n";
 
-my $scale = Imager::Matrix2d->scale(x=>1.2, 'y'=>0.8);
+my $scale = Imager::Matrix2d->scale('x'=>1.2, 'y'=>0.8);
 almost_equal($scale, [ 1.2, 0,   0,
                        0,   0.8, 0,
                        0,   0,   1 ]) or print "not ";
index 0358f9914509f107fe2495c65f0af279aedf79d0..39c6edf220ae5e78b9a9e2f3f04b3f5a4da522bf 100644 (file)
@@ -140,10 +140,10 @@ my $yellow = Imager::Color->new(255, 255, 0);
 $ffim->box(xmin=>10, ymin=>10, xmax=>20, ymax=>90, color=>$blue, filled=>1);
 $ffim->box(xmin=>20, ymin=>45, xmax=>80, ymax=>55, color=>$blue, filled=>1);
 $ffim->box(xmin=>80, ymin=>10, xmax=>90, ymax=>90, color=>$blue, filled=>1);
-ok(20, $ffim->flood_fill(x=>50, 'y'=>50, color=>$red), "flood fill");
+ok(20, $ffim->flood_fill('x'=>50, 'y'=>50, color=>$red), "flood fill");
 $diff = Imager::i_img_diff($rffcmp, $ffim->{IMG});
 ok(21, !$diff, "oo flood fill difference");
-$ffim->flood_fill(x=>50, 'y'=>50,
+$ffim->flood_fill('x'=>50, 'y'=>50,
                   fill=> {
                           hatch => 'check2x2'
                          });
index 46c73771bc5a26d48cfe2c2ece1abfc70c8a8751..a4bf0aab16f712bd5053273f73664a25ac2b53a1 100644 (file)
@@ -55,7 +55,7 @@ print "ok 3\n";
 
 my $img = Imager->new(xsize=>200, ysize=>200);
 my $font = Imager::Font->new(face=>$fontname, size=>20);
-$img->string(x=>30, y=>30, string=>"Imager", color=>NC(255, 0, 0), 
+$img->string('x'=>30, 'y'=>30, string=>"Imager", color=>NC(255, 0, 0), 
             font=>$font);
 $img->write(file=>'testout/t37_oo.ppm') or print "not ";
 print "ok 4 # ",$img->errstr||'',"\n";
index 6cc52643ce37b038790249fc593796cb1984c74e..415323e0380aac861acf910c8199366d5e118748 100644 (file)
@@ -79,7 +79,7 @@ close(FH);
 print "ok 3\n";
 
 #$fontname = 'fontfiles/arial.ttf';
-my $oof = Imager::Font->new(file=>$fontname, type=>'ft2', index=>0)
+my $oof = Imager::Font->new(file=>$fontname, type=>'ft2', 'index'=>0)
   or print "not ";
 print "ok 4\n";
 
@@ -87,8 +87,8 @@ my $im = Imager->new(xsize=>400, ysize=>250);
 
 $im->string(font=>$oof,
             text=>"Via OO",
-            x=>20,
-            y=>20,
+            'x'=>20,
+            'y'=>20,
             size=>60,
             color=>NC(255, 128, 255),
             aa => 1,
@@ -99,7 +99,7 @@ $oof->transform(matrix=>[1, 0.1, 0, 0, 1, 0])
 print "ok 6\n";
 $im->string(font=>$oof,
             text=>"Shear",
-            x=>20,
+            'x'=>20,
             'y'=>40,
             size=>60,
             sizew=>50,
@@ -112,7 +112,7 @@ $oof->transform(matrix=>m2d_rotate(degrees=>-30));
 #$oof->transform(matrix=>m2d_identity());
 $im->string(font=>$oof,
             text=>"SPIN",
-            x=>20,
+            'x'=>20,
             'y'=>50,
             size=>50,
            sizew=>40,
@@ -122,7 +122,7 @@ $im->string(font=>$oof,
 and
 $im->string(font=>$oof,
             text=>"SPIN",
-            x=>20,
+            'x'=>20,
             'y'=>50,
             size=>50,
            sizew=>40,
@@ -147,7 +147,7 @@ if ($] >= 5.006) {
   #$text = "A".chr(0x2010)."A"; # this one works too
   if ($im->string(font=>$oof,
               text=>$text,
-              x=>20,
+              'x'=>20,
               'y'=>200,
               size=>50,
               color=>NC(0,255,0),
@@ -168,7 +168,7 @@ my $text = pack("C*", 0x41, 0xE2, 0x80, 0x90, 0x41);
 #substr($text, -1, 0) = '';
 if ($im->string(font=>$oof,
                 text=>$text,
-                x=>20,
+                'x'=>20,
                 'y'=>230,
                 size=>50,
                 color=>NC(255,128,0),
@@ -191,7 +191,7 @@ for my $steps (0..39) {
   # $oof->hinting(hinting=>1);
   $im->string(font=>$oof,
               text=>"SPIN",
-              x=>160,
+              'x'=>160,
               'y'=>70,
               size=>65,
               color=>NC(255, $steps * 5, 200-$steps * 5),