[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Catch direction operators
From: |
Urs Liska |
Subject: |
Re: Catch direction operators |
Date: |
Sun, 29 Sep 2013 11:29:39 +0200 |
User-agent: |
K-9 Mail for Android |
David Kastrup <address@hidden> schrieb:
>Urs Liska <address@hidden> writes:
>
>> Hi David,
>>
>> this is great!
>>
>> Am 29.09.2013 09:51, schrieb David Kastrup:
>>> David Kastrup <address@hidden> writes:
>>>
>>>> colorizeDir =
>>>> #(define-music-function (parser location item)
>>>> (symbol-list-or-music?)
>>>> (define (grob-colorize-dir grob)
>>>> (let ((ev (event-cause grob)))
>>>> (and ev (ly:event-property ev 'direction #f)
>>>> red)))
>>>> #{ \tweak color #grob-colorize-dir #item #})
>>> Not everything might be prepared to deal with a color #f, so it may
>be
>>> safer to write the slightly more complex
>>>
>>> (if (and ev (ly:event-property ev 'direction #f))
>>> red '())
>>>
>>> expression inside.
>>>
>> Could you please explain to me (or give a few hints) what this last
>> (and) expression does exactly?
>
>if ev is non-#f and the property with the name 'direction in ev is
>non-#f (while considering an unset direction as defaulting to #f), then
>red is returned, otherwise '().
Ok, that's how I understood it (seems I'm slowly getting into the topic).
>
>> I would like to extend this to treat up/down independently
>>
>>
>> I tried to modify it as follows:
>>
>> colorizeDir =
>>
>> #(define-music-function (parser location item)
>>
>> (symbol-list-or-music?)
>>
>> (define (grob-colorize-dir grob)
>>
>> (let ((ev (event-cause grob)))
>>
>> (if (and ev (ly:event-property ev 'direction #f))
>>
>> (cond ((equal? 'direction 1) red)
>
>The symbol 'direction is a symbol and never equal to a number. You
>forgot to look up the property, instead comparing with the _name_ of
>the
>property.
>
>Any reason for the double-spacing here?
No idea how that happened. Before sending the message looked completely normal.
> It's a nuisance to quote and
>comment on.
Sorry!
>
>You can write:
>
>#(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?
Of course we can attribute it to you, and you can review it before release if
you want.
Best
Urs
- Catch direction operators, Urs Liska, 2013/09/28
- 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 <=
- Re: Catch direction operators, David Kastrup, 2013/09/29
- Re: Catch direction operators, Thomas Morley, 2013/09/29
- Re: Catch direction operators, David Kastrup, 2013/09/29
- Re: Catch direction operators, David Kastrup, 2013/09/29