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.
This commit is contained in:
Corwin Brust 2026-07-01 05:50:53 -05:00
parent b06ca3362b
commit 4b4a7fc52f
3 changed files with 61 additions and 8 deletions

View file

@ -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