[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Catch direction operators
From: |
David Kastrup |
Subject: |
Re: Catch direction operators |
Date: |
Sun, 29 Sep 2013 17:04:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Thomas Morley <address@hidden> writes:
>>>>You can write:
>>>>colorizeDir =
>>>>#(define-music-function (parser location item)
>>>> (symbol-list-or-music?)
>>>> (define (grob-colorize-dir grob)
>>>> (let ((ev (event-cause grob)))
>>>> (case (ly:event-property ev 'direction)
>>>> ((1) red)
>>>> ((-1) blue)
>>>> (else '()))))
>>>> #{ \tweak color #grob-colorize-dir #item #})
>>>
>>> Thanks, this works perfectly.
>>>
>>> I would like to add this to a Frescobaldi addition and later (once
>>> 2.18 is out) to a LilyPond addition proposal. Do you have any
>>> objections?
>>
>> 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.
>
> I thought it would be nice to apply such a function to not only one
> grob, but rather a list of grobs or all possible grobs.
> Though, I didn't manage to generalize David K's tweak-function.
Here is a generalization:
colorizeDir =
#(define-music-function (parser location item)
(symbol-list-or-music?)
(define (grob-colorize-dir grob)
(let ((ev (event-cause grob)))
(case (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) #})
\new Voice \with { \mapList #colorizeDir Slur.StringNumber.TextScript }
{
a4-( b)
a4^( b)
a''4_( b)
c''-3\4-"xy"
c''_3^\4^"xy"
c''^3_\4_"xy"
}
--
David Kastrup
- Re: Catch direction operators, (continued)
- Re: Catch direction operators, David Nalesnik, 2013/09/28
- Re: Catch direction operators, Urs Liska, 2013/09/29
- Re: Catch direction operators, David Kastrup, 2013/09/29
- Re: Catch direction operators, David Kastrup, 2013/09/29
- Re: Catch direction operators, Urs Liska, 2013/09/29
- Re: Catch direction operators, David Kastrup, 2013/09/29
- Re: Catch direction operators, Urs Liska, 2013/09/29
- Re: Catch direction operators, David Kastrup, 2013/09/29
- Re: Catch direction operators, Thomas Morley, 2013/09/29
- Re: Catch direction operators,
David Kastrup <=
- Re: Catch direction operators, David Kastrup, 2013/09/29
Re: Catch direction operators, MING TSANG, 2013/09/29