#!perl -wl

# creates a PBM image of the interval (0,1) becoming divided by the
# fractional parts of integer multiples of the golden ratio.

# perl phi-mod-1.pl 618 62 9 | pnmpad -black -l 1 -r 1 | pnmpad -white -t 10 -b 9 -l 10 -r 10 | pnmtopng > out.png

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <https://www.gnu.org/licenses/>.

die unless ($w,$h,$thick)=@ARGV;
$totalh=$h*($thick+1)+1;
print "P1\n$w $totalh";
@a=(0)x$w;
$phi=(1+sqrt(5))/2;
for(1..$w){
    print "1";
}
for(1..$h){
    $y=$phi * $_;
    $y -= int$y;
    $y*=$w;
    $y=int$y;
    die if ($w<=$y);
    $a[$y]=1;
    #print STDERR $y;
    for(1..$thick){
        &out1(@a);
    }
    for(1..$w){
        print "1";
    }
    #print'';
}
sub out1{
    print for(@_);
    #print'';
}
