lilypond-user
[Top][All Lists]
Advanced

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

Re: Center-aligning objects in Scheme - slight improvement


From: Maximilian Albert
Subject: Re: Center-aligning objects in Scheme - slight improvement
Date: Mon, 12 Mar 2007 12:04:18 +0100
User-agent: IceDove 1.5.0.10 (X11/20070307)

Hi again,

below is a slight improvement of the previous version which saves you
from typing the whole function definition over and over again just to
change the markup text. The function 'hairpinWithCenteredText' takes a
single markup as argument. The usage should be straightforward (see the
example).

Max


%%% begin code %%%

hairpinWithCenteredText = #(define-music-function
                           (parser location text) (markup?)
#{
 \override Voice.Hairpin #'stencil = #(lambda (grob)
   (let ((ext (ly:stencil-extent (ly:hairpin::print grob) 0)))
      (ly:stencil-combine-at-edge
         (ly:stencil-aligned-to (ly:hairpin::print grob) 0 -1)
          1
         -1
          (ly:stencil-translate-axis
             (ly:stencil-aligned-to (ly:text-interface::print grob) 0 0)
             (/ (- (cdr ext) (car ext)) 2)
             0))))
        \override Voice.Hairpin #'text = $text
#})

hairpinMolto = \hairpinWithCenteredText \markup {\italic "molto"}
hairpinMore  = \hairpinWithCenteredText \markup {\bigger "moltissimo"}

\new Staff {
   \hairpinMolto c'2\< c'2\f
   \hairpinMore  c'2\< c'2\f
}

%%% end code %%%




reply via email to

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