emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnugo 82c5b64 351/357: [gnugo imgen] New fit func to ig


From: Stefan Monnier
Subject: [elpa] externals/gnugo 82c5b64 351/357: [gnugo imgen] New fit func to ignore bottom grid line
Date: Sun, 29 Nov 2020 14:51:55 -0500 (EST)

branch: externals/gnugo
commit 82c5b649f704972ddf67f009da37be30e7247765
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo imgen] New fit func to ignore bottom grid line
    
    * packages/gnugo/gnugo-imgen.el (gnugo-imgen--fit): New func.
    (gnugo-imgen-fit-window-height): Use ‘gnugo-imge--fit’.
    (gnugo-imgen-fit-window-height/no-grid-bottom): New func.
---
 gnugo-imgen.el | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gnugo-imgen.el b/gnugo-imgen.el
index 0c7f720..5709d33 100644
--- a/gnugo-imgen.el
+++ b/gnugo-imgen.el
@@ -78,16 +78,27 @@ a square position on the board.  A value less than 8 is 
taken as 8.")
   (interactive)
   (clrhash gnugo-imgen-cache))
 
+(defun gnugo-imgen--fit (board-size ignored-grid-lines)
+  (cl-destructuring-bind (L top R bot)
+      (window-inside-absolute-pixel-edges)
+    (ignore L R)
+    (/ (float (- bot top (* (frame-char-height)
+                            ignored-grid-lines)))
+       board-size)))
+
 (defun gnugo-imgen-fit-window-height (board-size)
   "Return the dimension (in pixels) of a square for BOARD-SIZE.
 This uses the TOP and BOTTOM components as returned by
 `window-inside-absolute-pixel-edges' and subtracts twice
 the `frame-char-height' (to leave space for the grid)."
-  (cl-destructuring-bind (L top R bot)
-      (window-inside-absolute-pixel-edges)
-    (ignore L R)
-    (/ (float (- bot top (* 2 (frame-char-height))))
-       board-size)))
+  (gnugo-imgen--fit board-size 2))
+
+(defun gnugo-imgen-fit-window-height/no-grid-bottom (board-size)
+  "Return the dimension (in pixels) of a square for BOARD-SIZE.
+This uses the TOP and BOTTOM components as returned by
+`window-inside-absolute-pixel-edges' and subtracts the
+`frame-char-height' (to leave top-line space for the grid)."
+  (gnugo-imgen--fit board-size 1))
 
 (defconst gnugo-imgen-palette '((32 . :background)
                                 (?. . :grid-lines)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]