I polished the function a bit further:
hairpinWithCenteredText = #(define-music-function
(parser location text) (markup?)
#{
\override Voice.Hairpin #'stencil = #(lambda (grob)
(ly:stencil-aligned-to
(ly:stencil-combine-at-edge
(ly:stencil-aligned-to (ly:hairpin::print grob) X CENTER)
Y
DOWN
(ly:stencil-aligned-to (ly:text-interface::print grob) X CENTER))
X LEFT))
\override Voice.Hairpin #'text = $text
#})
/Mats
Maximilian Albert 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 %%%
_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user
--
=============================================
Mats Bengtsson
Signal Processing
Signals, Sensors and Systems
Royal Institute of Technology
SE-100 44 STOCKHOLM
Sweden
Phone: (+46) 8 790 8463
Fax: (+46) 8 790 7260
Email: [EMAIL PROTECTED]
WWW: http://www.s3.kth.se/~mabe
=============================================
_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user