[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c4a7d82 1/2: [gnugo imgen] New fit func to ignore bottom g
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] master c4a7d82 1/2: [gnugo imgen] New fit func to ignore bottom grid line |
Date: |
Tue, 14 Mar 2017 03:12:27 -0400 (EDT) |
branch: master
commit c4a7d820f87439e64f78d126dc34eaa96606566f
Author: Thien-Thi Nguyen <address@hidden>
Commit: Thien-Thi Nguyen <address@hidden>
[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.
---
packages/gnugo/gnugo-imgen.el | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/packages/gnugo/gnugo-imgen.el b/packages/gnugo/gnugo-imgen.el
index 0c7f720..5709d33 100644
--- a/packages/gnugo/gnugo-imgen.el
+++ b/packages/gnugo/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)