[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Catch direction operators
From: |
Paul Morris |
Subject: |
Re: Catch direction operators |
Date: |
Tue, 8 Oct 2013 11:11:26 -0700 (PDT) |
dak wrote
> You can add it wherever you want. I don't see it making any sense as an
> addition to LilyPond proper as it is a rather special use case. It may
> still be nice as a snippet as it is simple, flexible, and powerful. The
> use cases also show \tweak as an internal workhorse for both tweaks and
> overrides.
>
> As a snippet, it makes sense _in_ 2.18 as it illustrates current
> programming techniques.
This is great! I'd be glad to add it to the LSR. I have the following
which shows how to use it for both all grobs and just for certain grobs.
-Paul
%% BEGIN SNIPPET %%
\version "2.17"
colorizeDir =
#(define-music-function (parser location item)
(symbol-list-or-music?)
(define (grob-colorize-dir grob)
(let ((ev (event-cause grob)))
(case (and ev (ly:event-property ev 'direction))
((1) red)
((-1) blue)
(else '()))))
#{ \tweak color #grob-colorize-dir #item #})
mapList =
#(define-music-function (parser location fun lst)
(ly:music-function? list?)
#{ $@(map (lambda (s) #{ $fun $s #}) lst) #})
%% EXAMPLES %%
music =
{
a2-( b)
a^( b)
a''_( b)
c''-3\4-"xy"
c''_3^\4^"xy"
c''^3_\4_"xy"
}
\new Voice \with { \mapList #colorizeDir Slur.TextScript }
{ \music }
\new Voice \with { \mapList #colorizeDir #(map car all-grob-descriptions) }
{ \music }
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/Catch-direction-operators-tp151552p151994.html
Sent from the User mailing list archive at Nabble.com.
- Re: Catch direction operators,
Paul Morris <=