#!/usr/bin/env perl # Build a full screen black/white checkerboard using imagemagick (the hard way) # Rick van der Zwet, 2009 $BLOCK_SIZE=100; ($WIDTH, $HEIGHT) = split(' ',`xrandr | awk '/\\*/ {print $$1}' | tr 'x' ' '`); print "Screen: ". $WIDTH . "x" . $HEIGHT . "\n"; $X_NUM=$HEIGHT/$BLOCK_SIZE; $Y_NUM=$WIDTH/$BLOCK_SIZE; $X_NUM--; $Y_NUM--; print "Blocks x,y: " . $X_NUM . "," . $Y_NUM . "\n"; $FILE='chessboard.gif'; #`convert -size 640x480 pattern:checkerboard -monochrome gif:$FILE`; #`display gif:$FILE` ; $SIZE=" -size ${BLOCK_SIZE}x${BLOCK_SIZE}"; $LINE = []; $COLOR="black"; $LINESTART="black"; sub blockswap() { if ($COLOR eq "black") { $COLOR = "white"; } else { $COLOR = "black"; } } sub newline() { if ($LINESTART eq "black") { $LINESTART = "white"; } else { $LINESTART = "black"; } $COLOR=$LINESTART; } for($i = 0; $i < $X_NUM; $i++) { for($j =0; $j < $Y_NUM; $j++) { print "Block $i,$j\n"; $LINE[$i] = $LINE[$i] . $SIZE . " xc:$COLOR"; blockswap(); } newline(); } for($i = 0; $i < $X_NUM; $i++) { $LINE[$i] = " \\(" . $LINE[$i] . " +append \\) -append "; } $CMD = "convert" . join(" ",@LINE) . " gif:$FILE"; print $CMD; `$CMD`; `display gif:$FILE`;