b4236089ae5def175768189804c8d41d3926fd8b
[xscreensaver] / hacks / bubbles-tools / xpm2default
1 #!/usr/bin/perl
2 #----------------------------------------------------------------------------
3 #  Copyright (C) 1995-1996 James Macnicol
4 #
5 #   This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 1, or (at your option) any later
8 # version.
9 #
10 #   This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # for more details.
14 #-----------------------------------------------------------------------------
15 #
16 # Prints to the stdout a file suitable for use as bubbles_default.c for the
17 # bubbles screensaver (i.e. the default bubble which is compiled into the
18 # executable).  A list of XPMs is expected as input, e.g. output from the 
19 # pov2xpm script in this directory.
20 #
21 # Remember to change the path to your perl executable at the top of the
22 # script if it is wrong.
23 #
24 # Examples of usage:
25 #
26 #       pov2xpm sample.pov | xpm2default > bubbles_default.c
27 #
28 #  A new set of bubbles is first created with pov2xpm then passed to this
29 # script which places the C wrapper around the data and finally dumps the
30 # output into bubbles_default.c.
31 #
32 #       xpm2default < sample.xpm > bubbles_default.c
33 #
34 #  Same as the previous example except the XPM data came from a file rather
35 # than a pipe.
36 #
37 $numargs = @ARGV;
38 print "#include \"bubbles.h\"\n";
39 print "\n";
40 print "#ifndef NO_DEFAULT_BUBBLE\n";
41 print "\n";
42 print "char *default_ball_data[] = {\n";
43 while (<STDIN>) {
44         chop;
45         s/"/\\"/g;
46         print "\"$_\",\n";      
47 }
48 print "(char *)0\n";
49 print "};\n";
50 print "\n";
51 print "#endif\n";