lilypond-user
[Top][All Lists]
Advanced

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

Re: Center-aligning objects in Scheme


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

Hi Vivian,

> I posted a message to this list a few days ago about automatically
> center-aligning some text under a Hairpin object (for example "molto" or
> "poco" ) but haven't received any responses. Whilst I've found how to
> combine markups using combine-at-edge I can't find how to center-align
> one to the other (if indeed this is possible, which I would hope it is.)
> Could someone give me some pointers about where to begin? It would save
> me a lot of time if I could get this working.

Below is a a piece of code that hopefully solves your problem. My scheme
knowledge is still quite limited and I have almost no experience in
using lilypond's scheme functions, so any gurus may want to make this
ad-hoc hack considerably shorter or more elegant. But at least I hope it
works.

Cheers,
Max


%%% begin code %%%

hairpinMolto = {
\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 =
                                \markup { \smaller \italic "molto" }
}

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

%%% end code %%%




reply via email to

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