source: liacs/mms/project/chessboard.pl@ 64

Last change on this file since 64 was 23, checked in by Rick van der Zwet, 15 years ago

Final commit of report to be handed in.

  • Property svn:executable set to *
File size: 1.3 KB
RevLine 
[19]1#!/usr/bin/env perl
2# Build a full screen black/white checkerboard using imagemagick (the hard way)
3# Rick van der Zwet, 2009
4$BLOCK_SIZE=100;
5
6($WIDTH, $HEIGHT) = split(' ',`xrandr | awk '/\\*/ {print $$1}' | tr 'x' ' '`);
7print "Screen: ". $WIDTH . "x" . $HEIGHT . "\n";
8
[23]9$HEIGHT=600;
10$WIDTH=800;
11
[19]12$X_NUM=$HEIGHT/$BLOCK_SIZE;
13$Y_NUM=$WIDTH/$BLOCK_SIZE;
14
15$X_NUM--;
16$Y_NUM--;
17
18print "Blocks x,y: " . $X_NUM . "," . $Y_NUM . "\n";
19
20$FILE='chessboard.gif';
21#`convert -size 640x480 pattern:checkerboard -monochrome gif:$FILE`;
22#`display gif:$FILE` ;
23
24$SIZE=" -size ${BLOCK_SIZE}x${BLOCK_SIZE}";
25
26$LINE = [];
27
28$COLOR="black";
29$LINESTART="black";
30sub blockswap() {
31 if ($COLOR eq "black") {
32 $COLOR = "white";
33 } else {
34 $COLOR = "black";
35 }
36}
37
38sub newline() {
39 if ($LINESTART eq "black") {
40 $LINESTART = "white";
41 } else {
42 $LINESTART = "black";
43 }
44 $COLOR=$LINESTART;
45}
46
47for($i = 0; $i < $X_NUM; $i++) {
48 for($j =0; $j < $Y_NUM; $j++) {
49 print "Block $i,$j\n";
50 $LINE[$i] = $LINE[$i] . $SIZE . " xc:$COLOR";
51 blockswap();
52 }
53 newline();
54}
55
56for($i = 0; $i < $X_NUM; $i++) {
57 $LINE[$i] = " \\(" . $LINE[$i] . " +append \\) -append ";
58}
59
60$CMD = "convert" . join(" ",@LINE) . " gif:$FILE";
61print $CMD;
62`$CMD`;
Note: See TracBrowser for help on using the repository browser.