[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Center-aligning objects in Scheme - slight improvement
From: |
Trevor Bača |
Subject: |
Re: Center-aligning objects in Scheme - slight improvement |
Date: |
Wed, 14 Mar 2007 10:03:36 -0500 |
On 3/12/07, Maximilian Albert <address@hidden> wrote:
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 %%%
Just out of curiosity, can hairpinWithCenteredText add to the standard
distribution? (With magic numbers replaced by constants?)
--
Trevor Bača
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Center-aligning objects in Scheme - slight improvement,
Trevor Bača <=