#!/usr/local/bin/perl -w # # shifter.p # see also pepper.p pepperb.p pepperc.p # wallpaper.p # # writes an image with shifter properties. # $pbmplot = 1 ; $pbmfile = "figs/shifterl.pbm" ; $pbmx = 40 ; $d = 0.1 ; # density (rough) of black ink. No, I want the density of flipping events to be d. (along x or y) $pbmy = 2 ; $hprob = 0.75 ; $off = -1 ; $ascii = 1 ; # whether also to write an ascii summary to stdout. # eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; # $P = $pbmx * $pbmy ; if ( $ascii ) { print "$pbmx $pbmy\n" ; } if ( $pbmplot ) { # note I actually write a pgm file . open (PBM,"> $pbmfile"); print PBM "P1\n# CREATOR: wallpaper.p DJCM 98 11 09\n" ; print PBM "$pbmx $pbmy\n" ; # print PBM "$maxpbm\n" ; } for ( $i = 1 ; $i <= $P ; $i ++ ) { $c[$i] = 0 ; } $d=0 ; for ( $i = 1 ; $i <= $pbmx ; $i ++ ) { $d = ( rand() < $hprob ) ? 1-$d : $d ; $c[$i] = $d ; } $ii = 1 + $off ; $i = $pbmx + 1 ; for ( $t = 2 ; $t <= $pbmy ; $t ++ ) { for ( $iii = 1 ; $iii <= $pbmx ; $iii ++ ) { if ( $ii < 1 ) { $ii += $pbmx ; } if ( $ii > $pbmx ) { $ii -= $pbmx ; } print "$i from $ii ($c[$ii]) \n" ; $c[$i] = $c[$ii] ; $i ++ ; $ii ++ ; } } if ( $pbmplot ) { $tot = 0 ; $i0 = 0 ; for ( $i = 1 ; $i <= $pbmy ; $i ++ ) { for ( $j = 1 ; $j <= $pbmx ; $j ++ ) { $i0 ++ ; print PBM "$c[$i0] " ; $tot += $c[$i0] ; } print PBM "\n" ; } # bottom line close ( PBM ) ; print STDERR "$tot pixels high out of $P\n" ; } print STDERR "\n# xv $pbmfile\n" ;