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

4
NEWS
View file

@ -39,6 +39,10 @@ the mouse as well as the keyboard.
the middle, and your fanned hand, with the legal cards you may play 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 ringed. Click a card to play it. Set ~cg-trick-svg-cards~ to nil
for the plain-text board. 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): - 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 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 fanned hand with cursor, marks, and lay-off hints; click a card to

View file

@ -842,14 +842,9 @@ FS scales the N/S/E/W label fonts."
(svg-circle svg cx cy 3 :fill "#cfeccf"))) (svg-circle svg cx cy 3 :fill "#cfeccf")))
(defun cg-bid--draw-logo (svg cx cy &optional fs) (defun cg-bid--draw-logo (svg cx cy &optional fs)
"Draw a GNU Emacs emblem centred at CX, CY on SVG, scaled by FS." "Draw the configured Emacs emblem centred at CX, CY on SVG, scaled by FS.
(let ((fs (or fs 1.0))) The emblem is chosen with `cg-svg-emacs-logo'."
(svg-gradient svg "cg-logo" 'linear '((0 . "#8056c8") (100 . "#3f1f9e"))) (cg-svg-draw-logo svg cx cy fs))
(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-bid--grid-cell (bid gx gy cw ch g) (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. "Return (X Y W H) for BID in a grid at GX,GY with cells CW by CH, gutter G.

View file

@ -471,5 +471,59 @@ card-size slider beneath the row."
(cg-svg-slider-draw svg pad (+ pad h 8) cg-card-scale))) (cg-svg-slider-draw svg pad (+ pad h 8) cg-card-scale)))
(propertize "*" 'display (cg-svg-image svg (cg-scale)) 'cg-regions regions)))) (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) (provide 'cg-svg)
;;; cg-svg.el ends here ;;; cg-svg.el ends here