lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: \with-dimensions partially


From: Aaron Hill
Subject: Re: \with-dimensions partially
Date: Sat, 26 Dec 2020 13:37:21 -0800
User-agent: Roundcube Webmail/1.4.9

On 2020-12-26 1:12 pm, Fr. Samuel Springuel wrote:
Is there a way to set the horizontal dimensions of a markup to 0 while
leaving the vertical dimensions alone?

I’ve got the following as a start, but it zeros both X and Y
dimensions.  Ideally I’d like the second argument to be computed
automatically:

Cantor = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {\italic Cantors:}

Just need to define some custom markup functions. Consider these potential options:

%%%%
\version "2.20.0"

#(define-markup-command
  (with-dimension layout props axis interval markup)
  (number? number-pair? markup?)
  (let* ((sten (interpret-markup layout props markup))
         (xex (ly:stencil-extent sten X))
         (yex (ly:stencil-extent sten Y)))
   (ly:make-stencil
    (ly:stencil-expr sten)
    (if (eq? X axis) interval xex)
    (if (eq? Y axis) interval yex))))

#(define-markup-command
  (with-relative-dimensions layout props x-interval y-interval markup)
  (number-pair? number-pair? markup?)
  (define (interval-reindex interval indices)
   (cons
    (interval-index interval (car indices))
    (interval-index interval (cdr indices))))
  (let* ((sten (interpret-markup layout props markup))
         (xex (ly:stencil-extent sten X))
         (yex (ly:stencil-extent sten Y)))
   (ly:make-stencil
    (ly:stencil-expr sten)
    (interval-reindex xex x-interval)
    (interval-reindex yex y-interval))))

\markup {
  Lorem
  \circle \with-dimension #X #'(-1.5 . 1) \center-align !
  \circle \with-dimension #Y #'(-1 . 1.5) \vcenter !
  ipsum
  dolor
  \box \with-relative-dimensions #'(-1.5 . 1.5) #'(-0.5 . 0.5) sit
  amet.
}
%%%%

\with-dimension is like \with-dimensions but you specify which axis you want to modify.

\with-relative-dimensions is like \with-dimensions but the two intervals are computed relative to the extents of the markup, recalling that LEFT=DOWN=-1, CENTER=0, RIGHT=UP=1. And of course you can use any values in-between or outside those as desired.


-- Aaron Hill

Attachment: markup-dimensions.cropped.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]