branch: elpa/pacmacs
commit 528ca62e2810f8c23bb8b812c24a575df2bf3f2c
Merge: 2b9811e71b 4a94a72dd4
Author: rexim <[email protected]>
Commit: rexim <[email protected]>
Merge branch 'drop-xbm-support-141'. Close #141
---
pacmacs-image.el | 33 +++++++++++++++++++++------------
pacmacs-render.el | 9 +++++----
pacmacs.el | 2 +-
test/pacmacs-image-test.el | 16 ----------------
4 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/pacmacs-image.el b/pacmacs-image.el
index 8e444c8d11..1043589560 100644
--- a/pacmacs-image.el
+++ b/pacmacs-image.el
@@ -80,8 +80,24 @@
(if bit 1 0))))
result))
-(defun pacmacs--create-wall-tile (width
- height color
+(defun pacmacs--bits-to-xpm (bits width height)
+ (concat
+ "/* XPM */\n"
+ "static char *tile[] = {\n"
+ "/**/\n"
+ (format "\"%d %d 2 1\",\n" width height)
+ "\" c None\",\n"
+ "\". c #5555ff\",\n"
+ "/* pixels */\n"
+ (mapconcat
+ (lambda (row)
+ (format "\"%s\""
+ (mapconcat (-lambda (bit) (if bit "." " ")) row "")))
+ bits
+ ",\n")
+ "\n};"))
+
+(defun pacmacs--create-wall-tile (width height
bottom right
top left
@@ -110,7 +126,7 @@
(weight 3))
(dotimes (i width)
- (aset wall-block i (make-bool-vector height nil)))
+ (aset wall-block i (make-vector height nil)))
(when left-upper
(pacmacs--put-bits-dot wall-block 0 0 weight))
@@ -136,17 +152,10 @@
(when bottom
(pacmacs--put-horizontal-bar wall-block (- height weight)
width weight))
- (create-image wall-block 'xbm t :width width :height height
- :foreground color
- :background nil))
+ (create-image (pacmacs--bits-to-xpm wall-block width height)
+ 'xpm t))
pacmacs--wall-blocks))))
-(defun pacmacs-create-transparent-block (width height)
- (create-image
- (make-vector
- width (make-bool-vector height nil))
- 'xbm t :width width :height height))
-
(provide 'pacmacs-image)
;;; pacmacs-anim.el ends here
diff --git a/pacmacs-render.el b/pacmacs-render.el
index 0a7e6f4bad..3606baa326 100644
--- a/pacmacs-render.el
+++ b/pacmacs-render.el
@@ -36,13 +36,14 @@
(require 'pacmacs-anim)
(require 'pacmacs-board)
-(defvar pacmacs--empty-cell nil)
(defvar pacmacs--life-icon nil)
(defun pacmacs--render-empty-cell ()
- (when (not pacmacs--empty-cell)
- (setq pacmacs--empty-cell (pacmacs-create-transparent-block 40 40)))
- (pacmacs-insert-image pacmacs--empty-cell '(0 0 40 40)))
+ (pacmacs-insert-image (pacmacs--create-wall-tile
+ 40 40
+ nil nil nil nil
+ nil nil nil nil)
+ '(0 0 40 40)))
(defun pacmacs--render-life-icon ()
(when (not pacmacs--life-icon)
diff --git a/pacmacs.el b/pacmacs.el
index 4075f944d5..ffd3103b74 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -512,7 +512,7 @@
(defun pacmacs--wall-tile-at (row column)
(apply #'pacmacs--create-wall-tile
- 40 40 "#5555ff"
+ 40 40
(-map (-lambda ((row . column))
(not (pacmacs--wall-at-p row column)))
(append (pacmacs--possible-side-ways row column)
diff --git a/test/pacmacs-image-test.el b/test/pacmacs-image-test.el
index 6bf68f5a1c..aebc7999b6 100644
--- a/test/pacmacs-image-test.el
+++ b/test/pacmacs-image-test.el
@@ -36,22 +36,6 @@
(should (equal create-image-result
(pacmacs-create-color-block width height color))))))
-(ert-deftest pacmacs-create-transparent-block ()
- (let ((width 10)
- (height 20)
- (bool-vector-result 42)
- (make-vector-result 43)
- (create-image-result 44))
- (with-mock
- (mock (make-bool-vector height nil) => bool-vector-result :times 1)
- (mock (make-vector width bool-vector-result) => make-vector-result :times
1)
- (mock (create-image make-vector-result
- 'xbm t
- :width width
- :height height) => create-image-result :times 1)
- (should (equal create-image-result
- (pacmacs-create-transparent-block width height))))))
-
(ert-deftest pacmacs--put-bits-dot-test ()
(let ((input-bits (pacmacs--construct-2d-bool-vector
'((nil nil nil)