/usr/share/doc/libmath-planepath-perl/examples/sacks-xpm.pl is in libmath-planepath-perl 122-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #!/usr/bin/perl -w
# Copyright 2010, 2011, 2012 Kevin Ryde
# This file is part of Math-PlanePath.
#
# Math-PlanePath is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# Math-PlanePath is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
# Usage: perl sacks-xpm.pl >/tmp/foo.xpm # write image file
# xgzv /tmp/foo.xpm # view file
#
# This spot of code generates a big .xpm file showing all points of the
# SacksSpiral. XPM is a text format and can be generated quite easily as
# row strings. Use a graphics viewer program to look at it.
#
use 5.004;
use strict;
use POSIX ();
use Math::PlanePath::SacksSpiral;
my $width = 800;
my $height = 600;
my $spacing = 10;
my $path = Math::PlanePath::SacksSpiral->new;
my $x_origin = int($width / 2);
my $y_origin = int($height / 2);
my $n_max = ($x_origin/$spacing+2)**2 + ($y_origin/$spacing+2)**2;
my @rows = (' ' x $width) x $height;
foreach my $n ($path->n_start .. $n_max) {
my ($x, $y) = $path->n_to_xy ($n);
$x *= $spacing;
$y *= $spacing;
$x = $x + $x_origin;
$y = $y_origin - $y; # inverted
$x = POSIX::floor ($x + 0.5); # round
$y = POSIX::floor ($y + 0.5);
if ($x >= 0 && $x < $width && $y >= 0 && $y < $height) {
substr ($rows[$y], $x,1) = '*';
}
}
print <<"HERE";
/* XPM */
static char *sacks_xpm_pl[] = {
"$width $height 2 1",
" c black",
"* c white",
HERE
foreach my $row (@rows) {
print "\"$row\",\n";
}
print "};\n";
exit 0;
|