aboutsummaryrefslogtreecommitdiff
path: root/icons/square.pl
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2006-12-27 10:26:13 +0000
committerSimon Tatham <anakin@pobox.com>2006-12-27 10:26:13 +0000
commitd07eb2ea3a85913edb826a3e9c3ffc8abda71771 (patch)
treef9bd72ce6f4b92ccba9932667292baa4f72686e4 /icons/square.pl
parent90e6864579d740a6df3bdbbcf3cbc42cc5181d82 (diff)
downloadpuzzles-d07eb2ea3a85913edb826a3e9c3ffc8abda71771.zip
puzzles-d07eb2ea3a85913edb826a3e9c3ffc8abda71771.tar.gz
puzzles-d07eb2ea3a85913edb826a3e9c3ffc8abda71771.tar.bz2
puzzles-d07eb2ea3a85913edb826a3e9c3ffc8abda71771.tar.xz
Improve the icon images by cropping selected pieces out of most of
the main screenshots. (A few, like Map, were perfect already.) In the process I've vertically reflected the puzzle shown in the Pattern save file, to bring a more interesting piece of it into the top left corner :-) [originally from svn r7019]
Diffstat (limited to 'icons/square.pl')
-rwxr-xr-xicons/square.pl15
1 files changed, 12 insertions, 3 deletions
diff --git a/icons/square.pl b/icons/square.pl
index 81be9d7..815b94b 100755
--- a/icons/square.pl
+++ b/icons/square.pl
@@ -26,9 +26,18 @@ $al = scalar @$data;
die "wrong amount of image data ($al, expected $xl) from $infile\n"
unless $al == $xl;
-# Find the background colour. We assume the image already has a
-# border, so this is just the pixel colour of the top left corner.
-$back = $data->[0];
+# Find the background colour, by looking around the entire border
+# and finding the most popular pixel colour.
+for ($i = 0; $i < $w; $i++) {
+ $pcount{$data->[$i]}++; # top row
+ $pcount{$data->[($h-1)*$w+$i]}++; # bottom row
+}
+for ($i = 1; $i < $h-1; $i++) {
+ $pcount{$data->[$i*$w]}++; # left column
+ $pcount{$data->[$i*$w+$w-1]}++; # right column
+}
+@plist = sort { $pcount{$b} <=> $pcount{$a} } keys %pcount;
+$back = $plist[0];
# Crop rows and columns off the image to find the central rectangle
# of non-background stuff.