Function: gamegrid-xbm
gamegrid-xbm is a byte-compiled function defined in gamegrid.el.gz.
Signature
(gamegrid-xbm)
Documentation
Generate XBM format image used for each square.
Source Code
;; Defined in /usr/src/emacs/lisp/play/gamegrid.el.gz
;; Example of glyph in XBM format:
;;
;; /* gamegrid XBM */
;; #define gamegrid_width 16
;; #define gamegrid_height 16
;; static unsigned char gamegrid_bits[] = {
;; 0xff, 0xff, 0xff, 0x7f, 0xff, 0x3f, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a,
;; 0x57, 0x15, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a,
;; 0x57, 0x15, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00 };
(defun gamegrid-xbm ()
"Generate XBM format image used for each square."
(let* ((glyph-pixel-count (gamegrid-calculate-glyph-size))
(border-pixel-count (1- (/ glyph-pixel-count 4)))
(center-pixel-count (- glyph-pixel-count (* 2 border-pixel-count))))
(with-temp-buffer
(insert (format "\
/* gamegrid XBM */
#define gamegrid_width %s
#define gamegrid_height %s
static unsigned char gamegrid_bits[] = {
" glyph-pixel-count glyph-pixel-count))
(dotimes (row border-pixel-count)
(gamegrid-insert-xbm-bits
(concat (make-string (- glyph-pixel-count row) ?1)
(make-string row ?0)))
(insert ", \n"))
(let* ((left-border (make-string border-pixel-count ?1))
(right-border (make-string border-pixel-count ?0))
(even-line (apply 'concat
(append (list left-border)
(make-list (/ center-pixel-count 2) "10")
(list right-border))))
(odd-line (apply 'concat
(append (list left-border)
(make-list (/ center-pixel-count 2) "01")
(list right-border)))))
(dotimes (row center-pixel-count)
(gamegrid-insert-xbm-bits (if (oddp row) odd-line even-line))
(insert ", \n")))
(dotimes (row border-pixel-count)
(let ((edge-pixel-count (- border-pixel-count row)))
(gamegrid-insert-xbm-bits
(concat (make-string edge-pixel-count ?1)
(make-string (- glyph-pixel-count edge-pixel-count) ?0))))
(if (/= row (1- border-pixel-count))
(insert ", \n")
(insert " };\n")))
(buffer-string))))