Permalink
Browse files

fix off-by-one problem in infile, improve fur/tesla

  • Loading branch information...
1 parent 8a8d12a commit aa1985ed36db9d51e4604afdf2928e354c9d532d Alex Ayars committed Mar 14, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 lib/Math/Fractal/Noisemaker.pm
@@ -1,6 +1,6 @@
package Math::Fractal::Noisemaker;
-our $VERSION = '0.106';
+our $VERSION = '0.107';
use strict;
use warnings;
@@ -815,25 +815,29 @@ sub infile {
my $height = $img->getheight();
my $tempSize = ( $width > $height ) ? $width : $height;
- $tempSize--;
my $tempGrid = grid(%args, len => $tempSize);
for ( my $x = 0 ; $x < $tempSize ; $x++ ) {
my $column = $tempGrid->[$x];
for ( my $y = 0 ; $y < $tempSize ; $y++ ) {
- my $color = $img->getpixel(
- x => ( $x / $tempSize ) * ( $width - 1 ),
- y => ( $y / $tempSize ) * ( $height - 1 )
- );
+ my $color = $img->getpixel(x => $x, y => $y);
my ( $r, $g, $b ) = $color->rgba;
$column->set( $y, ( $r + $g + $b ) / 3 );
}
}
+ if ( $width > $len ) {
+ return shrink($tempGrid, %args);
+ } elsif ( $width < $len ) {
+ return grow($tempGrid, %args);
+ } else {
+ return $tempGrid;
+ }
+
return grow($tempGrid, %args);
}
@@ -2702,7 +2706,7 @@ sub fur {
my $multiresColumn = $multires->[$x];
my $column = $grid->[$x];
- my $heading = ( $multiresColumn->get($y) / $MAX_COLOR ) * 360;
+ my $heading = ( $multiresColumn->get($y) / $MAX_COLOR ) * 180;
if ( $args{tesla} ) {
### kink it up
@@ -3786,7 +3790,7 @@ Math::Fractal::Noisemaker - Visual noise generator
=head1 VERSION
-This document is for version 0.106 of Math::Fractal::Noisemaker.
+This document is for version 0.107 of Math::Fractal::Noisemaker.
=head1 SYNOPSIS

0 comments on commit aa1985e

Please sign in to comment.