[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Snippet for aligning markup inside another markup
From: |
Aaron Hill |
Subject: |
Re: Snippet for aligning markup inside another markup |
Date: |
Mon, 30 Sep 2019 11:16:07 -0700 |
User-agent: |
Roundcube Webmail/1.3.8 |
On 2019-09-30 6:18 am, Kieren MacMillan wrote:
Hi Michael,
for a project of mine I wanted to center a markup inside another
markup.
I searched the built-in markup functions, but to no avail. (Surely it
is
possible that I missed something...)
This is *almost* it, right?
%%% SNIPPET ENDS
\version "2.19.83"
boxone = \markup \with-color #blue \filled-box #'(0 . 6) #'(0 . 6) #0
boxtwo = \markup \with-color #red \filled-box #'(3 . 5) #'(5 . 7) #0
\markup \combine \halign #0 \boxone \halign #0 \boxtwo
%%% SNIPPET ENDS
I may be wrong, but I’m thinking there’s some relatively simple
incantation which would take it to the goal line.
Hopefully someone out there more knowledgeable than I will help.
Here's my take:
%%%%
\version "2.19.83"
#(define-markup-command (centered-overlay layout props args)
(markup-list?)
(ly:stencil-aligned-to
(interpret-markup layout props #{ \markup \halign #LEFT \overlay {
#@(map (lambda (m) #{ \markup \vcenter \halign #CENTER $m #})
args) } #})
Y DOWN))
boxone = \markup \with-color #yellow \filled-box #'(0 . 6) #'(0 . 6) #0
boxtwo = \markup \with-color #green \filled-box #'(3 . 5) #'(5 . 7) #0
\markup {
"\centered-overlay:"
\centered-overlay { \boxone "1" }
\centered-overlay { \boxtwo "2" }
\centered-overlay { \boxone \boxtwo "1+2" }
}
%%%%
-- Aaron Hill
centered-overlay.cropped.png
Description: PNG image