source: liacs/mss/project/chessboard.pl@ 21

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

Checkerboard generation (test field)

  • 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
9$X_NUM=$HEIGHT/$BLOCK_SIZE;
10$Y_NUM=$WIDTH/$BLOCK_SIZE;
11
12$X_NUM--;
13$Y_NUM--;
14
15print "Blocks x,y: " . $X_NUM . "," . $Y_NUM . "\n";
16
17$FILE='chessboard.gif';
18#`convert -size 640x480 pattern:checkerboard -monochrome gif:$FILE`;
19#`display gif:$FILE` ;
20
21$SIZE=" -size ${BLOCK_SIZE}x${BLOCK_SIZE}";
22
23$LINE = [];
24
25$COLOR="black";
26$LINESTART="black";
27sub blockswap() {
28 if ($COLOR eq "black") {
29 $COLOR = "white";
30 } else {
31 $COLOR = "black";
32 }
33}
34
35sub newline() {
36 if ($LINESTART eq "black") {
37 $LINESTART = "white";
38 } else {
39 $LINESTART = "black";
40 }
41 $COLOR=$LINESTART;
42}
43
44for($i = 0; $i < $X_NUM; $i++) {
45 for($j =0; $j < $Y_NUM; $j++) {
46 print "Block $i,$j\n";
47 $LINE[$i] = $LINE[$i] . $SIZE . " xc:$COLOR";
48 blockswap();
49 }
50 newline();
51}
52
53for($i = 0; $i < $X_NUM; $i++) {
54 $LINE[$i] = " \\(" . $LINE[$i] . " +append \\) -append ";
55}
56
57$CMD = "convert" . join(" ",@LINE) . " gif:$FILE";
58print $CMD;
59`$CMD`;
60`display gif:$FILE`;
61
Note: See TracBrowser for help on using the repository browser.