[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs f65f288b18 239/472: Cache wall tiles (#131)
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs f65f288b18 239/472: Cache wall tiles (#131) |
Date: |
Thu, 6 Jan 2022 21:59:28 -0500 (EST) |
branch: elpa/pacmacs
commit f65f288b1802eb9755321785754dc1eaed335596
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Cache wall tiles (#131)
---
pacmacs-image.el | 90 ++++++++++++++++++++++++++++++++++----------------------
1 file changed, 55 insertions(+), 35 deletions(-)
diff --git a/pacmacs-image.el b/pacmacs-image.el
index 513e08ef66..faf4443b32 100644
--- a/pacmacs-image.el
+++ b/pacmacs-image.el
@@ -32,7 +32,10 @@
;;; Code:
+(require 'dash)
+
(defconst pacmacs--flip-xbm-bits (eq system-type 'windows-nt))
+(defvar pacmacs--wall-blocks (make-vector 256 nil))
(defun pacmacs-load-image (filename)
(create-image filename 'xpm nil :heuristic-mask t))
@@ -69,45 +72,62 @@
(dotimes (i width)
(aset (aref bits (+ row w)) i t))))
+(defun pacmacs--bit-list-to-integer (bit-list)
+ (let ((result 0))
+ (dolist (bit bit-list)
+ (setq result (logior (lsh result 1)
+ (if bit 1 0))))
+ result))
+
(defun pacmacs--create-wall-block (width
height color
- bottom right top left
+
+ bottom right
+ top left
left-upper right-upper
left-bottom right-bottom)
- (let ((wall-block (make-vector
- width nil))
- (weight 3))
-
- (dotimes (i width)
- (aset wall-block i (make-bool-vector height nil)))
-
- (when left-upper
- (pacmacs--put-bits-dot wall-block 0 0 weight))
-
- (when right-upper
- (pacmacs--put-bits-dot wall-block 0 (- width weight) weight))
-
- (when left-bottom
- (pacmacs--put-bits-dot wall-block (- height weight) 0 weight))
-
- (when right-bottom
- (pacmacs--put-bits-dot wall-block (- height weight) (- width weight)
weight))
-
- (when left
- (pacmacs--put-vertical-bar wall-block 0 height weight))
-
- (when right
- (pacmacs--put-vertical-bar wall-block (- width weight) height weight))
-
- (when top
- (pacmacs--put-horizontal-bar wall-block 0 width weight))
-
- (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)))
+ (let ((cache-index
+ (pacmacs--bit-list-to-integer
+ (list bottom right top left
+ left-upper right-upper
+ left-bottom right-bottom))))
+ (-if-let (cached-tile (aref pacmacs--wall-blocks cache-index))
+ cached-tile
+ (aset pacmacs--wall-blocks cache-index
+ (let ((wall-block (make-vector
+ width nil))
+ (weight 3))
+
+ (dotimes (i width)
+ (aset wall-block i (make-bool-vector height nil)))
+
+ (when left-upper
+ (pacmacs--put-bits-dot wall-block 0 0 weight))
+
+ (when right-upper
+ (pacmacs--put-bits-dot wall-block 0 (- width weight) weight))
+
+ (when left-bottom
+ (pacmacs--put-bits-dot wall-block (- height weight) 0 weight))
+
+ (when right-bottom
+ (pacmacs--put-bits-dot wall-block (- height weight) (- width
weight) weight))
+
+ (when left
+ (pacmacs--put-vertical-bar wall-block 0 height weight))
+
+ (when right
+ (pacmacs--put-vertical-bar wall-block (- width weight) height
weight))
+
+ (when top
+ (pacmacs--put-horizontal-bar wall-block 0 width weight))
+
+ (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))))))
(defun pacmacs-create-transparent-block (width height)
(create-image
- [nongnu] elpa/pacmacs e64420ace4 209/472: Fix meta for Red-Ghost-Win animation, (continued)
- [nongnu] elpa/pacmacs e64420ace4 209/472: Fix meta for Red-Ghost-Win animation, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs bfb089d1de 213/472: Exctract init code to a function (#115), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 09c0a15f40 217/472: Get pacmacs--object-at-p back (#122), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs daca08b8b1 219/472: Add another it case (#122), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ed46a4b500 221/472: Add big pills sprites. Close #82, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ca32745bcb 224/472: Refactor char making duplicate code (#81), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 5f7b4fcb12 235/472: Rename pacmacs--put-dot function (#131), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ba28d344be 068/472: Remove copypaste (#54), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 49e0ff0fe8 020/472: Cask: take package info from pacman.el file, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7a8db8e06c 228/472: Merge branch 'xbm-flip-bit-hack-133'. Close #133, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs f65f288b18 239/472: Cache wall tiles (#131),
ELPA Syncer <=
- [nongnu] elpa/pacmacs edf7600fca 237/472: Add functions for drawing bars (#131), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2a9ec76c28 263/472: Automate Big Pills sprites generating (#26), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a1bf99c5f7 176/472: Add an animation, close #118., ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 29b87c4538 181/472: Refactor out unpaused play state predicate, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 93f964e11e 186/472: Merge branch 'compile-on-ci-123'. Close #123, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 3f7bf5c282 192/472: Fix board UTs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 805d91d22b 194/472: Rename all the buffer stuff to board back (#105), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1ab8264214 198/472: Remove dead vars for board size (#126), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 144a973d83 203/472: Merge branch 'slow-object-look-up-126'. Close #126, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 6a4bf8c87f 214/472: Merge branch 'integration-test-recorder-115'. Close #115, ELPA Syncer, 2022/01/06