Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
;; Create and preview xpms and favicons using emacs.
;; Copyleft 2005-2009, Eduardo Ochs <eduardoochs@gmail.com>.
;; First version:   2005nov05.
;; Current version: 2009aug03.
;; Trivial changes: 2012may04.
;; Source:   <http://angg.twu.net/elisp/myxpm.el>
;; Htmlized: <http://angg.twu.net/elisp/myxpm.el.html>

;; How to use this: load with
;;   (load-file "myxpm.el")
;; then execute the `find-myxpmscaled+' sexps by hand.

;; «.find-myxpmscaled+»	(to "find-myxpmscaled+")
;; «.eev-icon»		(to "eev-icon")
;; «.blogme-icon»	(to "blogme-icon")
;; «.dednat4-icon»	(to "dednat4-icon")
;; «.rrj»		(to "rrj")
;; «.littlelangs»	(to "littlelangs")
;; «.transparent-fav»	(to "transparent-fav")
;; «.forthsun»		(to "forthsun")
;; «.ninecolors»	(to "ninecolors")
;; «.gab»		(to "gab")

;; (find-angg ".emacs" "find-xpm")
;; (find-fline "/usr/X11R6/include/X11/xpm.h")
;; http://www.w3.org/People/danield/xpm_story.html
;; (find-w3m "$S/http/www.w3.org/People/danield/xpm_story.html" "multi syntax:")

(defun myxpm-quote (str) (format "\"%s\"" str))
(defun myxpm-strings (strs) (mapconcat 'myxpm-quote strs ",\n"))
(defun myxpm-block (ttl strs) (format "/* %s */\n%s" ttl (myxpm-strings strs)))
(defun myxpm-3blocks (varname numbers colors grid)
  (if (listp numbers) (setq numbers (apply 'format "%d %d %d %d" numbers)))
  (format "/* XPM */\nstatic char *%s[] = {\n%s,\n%s,\n%s\n};\n"
	  (or varname "noname")
	  (myxpm-block "width height ncolors chars_per_pixel" (list numbers))
	  (myxpm-block "colors" colors)
	  (myxpm-block "pixels" grid)))

(defun myxpm-ccode (varname colors grid)
  (myxpm-3blocks
   varname (list (length (car grid)) (length grid) (length colors) 1)
   colors grid))

(defun myxpm-xtimes (xscale str)
  (mapconcat (lambda (c) (concat (make-list xscale c))) str ""))
(defun myxpm-ytimes (yscale strs)
  (apply 'append (mapcar (lambda (str) (make-list yscale str)) strs)))
(defun myxpm-xytimes (xscale yscale grid)
  (myxpm-ytimes yscale (mapcar (lambda (str) (myxpm-xtimes xscale str)) grid)))

(defun find-myxpm (colors grid &optional convert-to)
  (ee-write-string (myxpm-ccode nil colors grid) "$EEVTMPDIR/ee.xpm")
  (find-fline "$EEVTMPDIR/ee.xpm")
  (if convert-to (find-sh0 (format "convert $EEVTMPDIR/ee.xpm %s" convert-to)))
  (list (length (car grid)) (length grid)))

(defun find-myxpmscaled (xscale yscale colors grid &optional convert-to)
  (find-myxpm colors (myxpm-xytimes xscale yscale grid) convert-to)
  (list (length (car grid)) (length grid)))

;; «find-myxpmscaled+»  (to ".find-myxpmscaled+")
(defun find-myxpmscaled+ (colors grid &optional convert-to scale)
  (cond ((numberp scale) (find-myxpm colors (myxpm-xytimes scale scale grid)))
	(scale           (find-myxpm colors grid convert-to)) ; try to save
	(t               (find-myxpm colors grid)))	      ; no saving
  (list (length (car grid))
	(length grid)
	(cond ((numberp scale) `(scaled ,scale))
	      (scale `(save into ,convert-to)))))

;; Tests:
;; (myxpm-xtimes 3 "abcde")
;; (myxpm-ytimes 3 '("a" "bc"))
;; (myxpm-xytimes 2 3 '("a" "bc" "def"))
;; (setq myxpm-colors '(". c #ffbb00" "o c red" "- c lime green"))
;; (find-estring (myxpm-ccode nil myxpm-colors '("...." "..oo" "--oo")))
;; (find-myxpm           myxpm-colors '("...." "..oo" "--oo"))
;; (find-myxpmscaled 8 8 myxpm-colors '("...." "..oo" "--oo"))

;; (find-ecolors)
;; (find-sh "wish <(echo 'puts [tk_chooseColor]; exit')")

;; «eev-icon»  (to ".eev-icon")
;; (find-anggfile "eev-current/eev-icon.png")
;;
' (find-myxpmscaled+
    '("  c none"
      ". c olive drab"
      "O c #eeffe5")
    '("                "
      "............... "
      "............... "
      "............... "
      "............... "
      "............... "
      ".OO...OO..O...O "
      "O..O.O..O.O...O "
      "OOOO.OOOO..O.O. "
      "O....O.....O.O. "
      ".OO...OO....O.. "
      "............... "
      "............... "
      "............... "
      "............... "
      "............... ")
    ;; "~/eev-current/eev-icon.png" t
    "/tmp/eev_16.png" 2
    )

;; (find-fline "/tmp/")

;; (eev "convert $EEVTMPDIR/ee.xpm /tmp/favicon.ico && Scp /tmp/favicon.ico angg.twu.net:slow_html/ && Scp /tmp/favicon.ico angg.twu.net:public_html/")
;; (eev "display $EEVTMPDIR/ee.xpm")
;; (eev "display /tmp/favicon.ico")

;; «blogme-icon»  (to ".blogme-icon")
;; (find-anggfile "blogme/blogme-icon.png")
' (find-myxpmscaled+
    '("  c none"
      ". c #ffbb00"
      "O c #ff6600")
    '("                "
      "............... "
      "............... "
      "............... "
      "............... "
      "...OOO...OOO... "
      "...O.......O... "
      "...O.......O... "
      "...O.......O... "
      "...O.......O... "
      "...O.......O... "
      "...OOO...OOO... "
      "............... "
      "............... "
      "............... "
      "............... ")
    "~/blogme/blogme-icon.png" 4)

;; (find-sh0 "cp -v ~/blogme/blogme-icon.png ~/blogme3/.favicon.png")

' (find-myxpmscaled+
    '(". c none"
      "  c black"
      "o c bisque"
      "4 c red")
    '("................"
      "                "
      "                "
      "                "
      "                "
      "   o o          "
      "   o o     4    "
      "  ooooo  4 4 4  "
      "   o o    444   "
      "  ooooo  4 4 4  "
      "   o o     4    "
      "   o o          "
      "                "
      "                "
      "                "
      "                ")
    "~/eev-current/eev-glyph-icon.png" 4)

;; «dednat4-icon»  (to ".dednat4-icon")
;; (find-anggfile "dednat4/dednat4-icon.png")
;;
' (find-myxpmscaled+
    '(". c none"
      "  c antiquewhite1"
      "a c sienna"
      "b c brown"
      "c c brown"
      "d c brown"
      "o c blue4")
    '(" b     o    aa  "
      " bb   ooooo   a "
      " b b o      aaa "
      " bbb  ooooo aaa "
      "       o        "
      " ooo        ooo "
      "  o          o  "
      "  o          o  "
      "  o          o  "
      " ooo        ooo "
      "  o          o  "
      "        o       "
      "  cc ooooo    d "
      " c        o  dd "
      " c   ooooo  d d "
      "  cc    o   ddd ")
    "~/dednat4/dednat4-icon.png" 4)

;; «rrj»  (to ".rrj")
;; (find-anggfile "IMAGES/rrj.png")
;;
' (find-myxpmscaled+
    '(". c none"
      "  c white"
      "o c black")
    '("                "
      "                "
      "                "
      "             o  "
      "                "
      " o oo o oo   o  "
      " oo   oo     o  "
      " o    o      o  "
      " o    o      o  "
      " o    o      o  "
      " o    o   o  o  "
      "           oo   "
      "                "
      "                "
      "                "
      "                ")
    "~/IMAGES/rrj.png" 4)

;; (find-ecolors)
' (find-myxpmscaled+
    '("  c mediumblue"
      "o c lightgrey"
      "b c blue"
      "a c navyblue"
      "c c blue3")
    '("                "
      "                "
      "                "
      "                "
      "                "
      "      bbbb      "
      "  oo  bbbb  oo  "
      "  oo  bbbb  oo  "
      "      bbbb      "
      "      bbbb      "
      "  oo  bbbb  oo  "
      "  oo  bbbb  oo  "
      "             o  "
      "            o   "
      "                "
      "                ")
    "~/IMAGES/forth.png" 1)

;; «littlelangs»  (to ".littlelangs")
;; (find-angg "IMAGES/littlelangs.png")
;; (find-ecolors)
' (find-myxpmscaled+
    '("  c firebrick"
      "o c orange")
    '("                "
      "                "
      "                "
      "                "
      "  oo     oo     "
      "  oo     oo     "
      "  oo     oo     "
      "  oo     oo     "
      "  oo     oo     "
      "  oo     oo     "
      "  ooooo  ooooo  "
      "  ooooo  ooooo  "
      "                "
      "                "
      "                "
      "                ")
    "~/IMAGES/littlelangs.png" 1)

;; «transparent-fav»  (to ".transparent-fav")
' (find-myxpmscaled+
    '("  c none")
    (make-list 16 "                ")
    "~/IMAGES/transparent-fav.png" 2)

;; «forthsun»  (to ".forthsun")
;; (find-anggfile "IMAGES/forthsun.png")
' (find-myxpmscaled+
    '("  c white"
      "x c black"
      "y c gold  "
    ;;"o c lightgrey"
      "o c black"
      "b c blue"
      "a c navyblue"
      "c c blue3")
    '("        xxxxyyyy"
      "           xyyyy"
      "          xxyyyy"
      "        xx  xyyy"
      "           x xxx"
      "          x  x x"
      "            x  x"
      "            x  x"
      "  oo  oo        "
      "  oo  oo        "
      "                "
      "  oo  oo        "
      "  oo  oo        "
      "       o        "
      "      o         "
      "                ")
    "~/IMAGES/forthsun.png" t)

' (find-myxpmscaled+
    '("  c white"
      "x c black"
      "y c gold  "
    ;;"o c lightgrey"
      "o c black"
      "b c blue"
      "a c navyblue"
      "c c blue3")
    '("                "
      "           bbbb "
      "          bbb   "
      "         bbb    "
      "         bbb    "
      "         bbb    "
      "          bbb   "
      "           bbbb "
      "  oo  oo        "
      "  oo  oo        "
      "                "
      "  oo  oo        "
      "  oo  oo        "
      "       o        "
      "      o         "
      "                ")
    "~/IMAGES/forthluawhite.png" t)

' (find-myxpmscaled+
    '("  c navyblue"
      "x c black"
      "y c gold  "
    ;;"o c lightgrey"
      "o c yellow"
      "b c white"
      "a c navyblue"
      "c c blue3")
    '("                "
      "           bbbb "
      "          bbb   "
      "         bbb    "
      "         bbb    "
      "         bbb    "
      "          bbb   "
      "           bbbb "
      "  oo  oo        "
      "  oo  oo        "
      "                "
      "  oo  oo        "
      "  oo  oo        "
      "       o        "
      "      o         "
      "                ")
    "~/IMAGES/forthlua.png" t)

;; «ninecolors»  (to ".ninecolors")
' (find-myxpmscaled+
    '("  c #FFFFFF"
      ". c #00FE44"
      "+ c #B7FE00"
      "@ c #FFC400"
      "# c #00ACFE"
      "% c #A1706B"
      "$ c #FC030B"
      "& c #042CFE"
      "* c #8703FE"
      "= c #FF00D6")
    '(".....+++++@@@@@ "
      ".....+++++@@@@@ "
      ".....+++++@@@@@ "
      ".....+++++@@@@@ "
      ".....+++++@@@@@ "
      "#####%%%%%$$$$$ "
      "#####%%%%%$$$$$ "
      "#####%%%%%$$$$$ "
      "#####%%%%%$$$$$ "
      "#####%%%%%$$$$$ "
      "&&&&&*****===== "
      "&&&&&*****===== "
      "&&&&&*****===== "
      "&&&&&*****===== "
      "&&&&&*****===== "
      "                ")
   "/tmp/9colors.png" 4)


;; «gab»  (to ".gab")
' (find-myxpmscaled+
    '("  c #FFFFFF"
      ;; ". c purple"
      ;; ". c darkmagenta"
      ". c saddlebrown"
      ;; "a c yellow"
      ;; "a c yellow"
      "a c #E4580B"
      "b c #3B3F1C"
      "c c #6C773D"
      ;; ". c #00FE44"
      "r c #C61A1A"
      "X c #C61A1A"
      "= c #FF00D6")
    '("aaaaaaaaaaaaaaaa"
      "aaaaaaaaaaaaaaaa"
      "aaaaaXXaaXXaaaaa"
      "aaaaaXXaaXXaaaaa"
      "aaaaaaaaaaaaaaaa"
      "aaaaaaaaaaaaaaaa"
      "aaaaaaaaaaaaaaaa"
      "bbbbbbbbbbbbbbbb"
      "bbbbbbbbbbbbbbbb"
      "bbbbbbbbbbbbbbbb"
      "cccccccccccccccc"
      "cccccccccccccccc"
      "cccccccccccccccc"
      "cccccccccccccccc"
      "cccccccccccccccc"
      "cccccccccccccccc")
   "/tmp/gab.png" t)





;;
;; Local Variables:
;; coding:               raw-text-unix
;; ee-delimiter-hash:    "\n#*\n"
;; ee-delimiter-percent: "\n%*\n"
;; ee-anchor-format:     "«%s»"
;; ee-comment-prefix:    ";;"
;; End: