From 4b4a7fc52f4e578bd78e4b73fcfbe71181d9c24f Mon Sep 17 00:00:00 2001 From: Corwin Brust Date: Wed, 1 Jul 2026 05:50:53 -0500 Subject: [PATCH] Switchable Emacs logo in the full-SVG UI * cg-svg.el (cg-svg-emacs-logo): new defcustom. (cg-svg--logo-files, cg-svg--logo-file, cg-svg--draw-logo-emblem, cg-svg-draw-logo): embed a real Emacs logo image via svg-embed, with the drawn emblem as a fallback. * cg-bid-ui.el (cg-bid--draw-logo): delegate to cg-svg-draw-logo. * NEWS: note the switchable logo. --- NEWS | 4 ++++ cg-bid-ui.el | 11 +++-------- cg-svg.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index ce5345c..9415860 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,10 @@ the mouse as well as the keyboard. the middle, and your fanned hand, with the legal cards you may play ringed. Click a card to play it. Set ~cg-trick-svg-cards~ to nil for the plain-text board. + - The Emacs emblem in the full-window (SVG) UIs is now switchable via + ~cg-svg-emacs-logo~: it embeds a real logo that ships with Emacs -- + the modern icon (default), the classic icon, a GNU head, or the + splash image -- or the small built-in drawn emblem, or none. - Full SVG board for the rummy games (Gin Rummy, Rummy, Rummy 500): the stock and discard, the melds already down on the table, and your fanned hand with cursor, marks, and lay-off hints; click a card to diff --git a/cg-bid-ui.el b/cg-bid-ui.el index 6803f80..ad980a3 100644 --- a/cg-bid-ui.el +++ b/cg-bid-ui.el @@ -842,14 +842,9 @@ FS scales the N/S/E/W label fonts." (svg-circle svg cx cy 3 :fill "#cfeccf"))) (defun cg-bid--draw-logo (svg cx cy &optional fs) - "Draw a GNU Emacs emblem centred at CX, CY on SVG, scaled by FS." - (let ((fs (or fs 1.0))) - (svg-gradient svg "cg-logo" 'linear '((0 . "#8056c8") (100 . "#3f1f9e"))) - (svg-circle svg cx cy (round (* 26 fs)) :gradient "cg-logo" - :stroke "#2a1370" :stroke-width 2) - (cg-svg--text svg "e" cx (+ cy (round (* 10 fs))) (round (* 30 fs)) "#ffffff" t) - (cg-svg--text svg "GNU Emacs" cx (+ cy (round (* 42 fs))) - (max 10 (round (* 11 fs))) "#c7bbe6"))) + "Draw the configured Emacs emblem centred at CX, CY on SVG, scaled by FS. +The emblem is chosen with `cg-svg-emacs-logo'." + (cg-svg-draw-logo svg cx cy fs)) (defun cg-bid--grid-cell (bid gx gy cw ch g) "Return (X Y W H) for BID in a grid at GX,GY with cells CW by CH, gutter G. diff --git a/cg-svg.el b/cg-svg.el index 5141276..7c5159d 100644 --- a/cg-svg.el +++ b/cg-svg.el @@ -471,5 +471,59 @@ card-size slider beneath the row." (cg-svg-slider-draw svg pad (+ pad h 8) cg-card-scale))) (propertize "*" 'display (cg-svg-image svg (cg-scale)) 'cg-regions regions)))) +(defcustom cg-svg-emacs-logo 'modern + "Which Emacs emblem to show in the full-window (svg-fill) games. +The image choices embed a logo that ships with Emacs, falling back to the +drawn emblem when the file is unavailable. `drawn' is a small built-in +emblem and `none' shows nothing." + :type '(choice (const :tag "Modern Emacs icon" modern) + (const :tag "Classic Emacs icon" classic) + (const :tag "GNU head (Gnus)" gnu) + (const :tag "GNU Emacs splash" splash) + (const :tag "Drawn emblem" drawn) + (const :tag "None" none)) + :group 'cg-svg) + +(defconst cg-svg--logo-files + '((modern . ("images/icons/hicolor/48x48/apps/emacs.png" + "images/icons/hicolor/128x128/apps/emacs.png")) + (classic . ("images/icons/hicolor/48x48/apps/emacs23.png" + "images/icons/hicolor/128x128/apps/emacs23.png")) + (gnu . ("images/gnus/gnus.png")) + (splash . ("images/splash.png"))) + "Map a logo name to candidate image files relative to `data-directory'.") + +(defun cg-svg--logo-file (name) + "Return the first readable image file for logo NAME, or nil." + (cl-loop for rel in (cdr (assq name cg-svg--logo-files)) + for f = (expand-file-name rel data-directory) + when (file-readable-p f) return f)) + +(defun cg-svg--draw-logo-emblem (svg cx cy fs) + "Draw the built-in purple GNU Emacs emblem centred at CX, CY, scaled FS." + (svg-gradient svg "cg-logo" 'linear '((0 . "#8056c8") (100 . "#3f1f9e"))) + (svg-circle svg cx cy (round (* 26 fs)) :gradient "cg-logo" + :stroke "#2a1370" :stroke-width 2) + (cg-svg--text svg "e" cx (+ cy (round (* 10 fs))) (round (* 30 fs)) "#ffffff" t) + (cg-svg--text svg "GNU Emacs" cx (+ cy (round (* 42 fs))) + (max 10 (round (* 11 fs))) "#c7bbe6")) + +(defun cg-svg-draw-logo (svg cx cy &optional fs) + "Draw the configured Emacs emblem (`cg-svg-emacs-logo') centred at CX, CY. +FS scales it. Embeds a real Emacs logo image when one is available, and +otherwise draws the built-in emblem." + (let ((fs (or fs 1.0)) (choice cg-svg-emacs-logo)) + (pcase choice + ('none nil) + ('drawn (cg-svg--draw-logo-emblem svg cx cy fs)) + (_ (let ((file (and (fboundp 'svg-embed) (cg-svg--logo-file choice)))) + (if (null file) + (cg-svg--draw-logo-emblem svg cx cy fs) + (let ((size (round (* 56 fs)))) + (svg-embed svg file "image/png" nil + :x (round (- cx (/ size 2))) + :y (round (- cy (/ size 2))) + :width size :height size)))))))) + (provide 'cg-svg) ;;; cg-svg.el ends here