lilypond-user
[Top][All Lists]
Advanced

[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 10:30:14 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7

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?
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)
                ((equal? 'direction -1) blue))
          '())))
  #{ \tweak color #grob-colorize-dir #item #})


and hoped if would work like this:
"if we are dealing with the right grob, and this grob has a 'direction then
execute the 'cond' _expression_ and assign grob-colorize-dir 'red' or 'blue' depending on the 'direction being 1 or -1"


It compiles without complaints but doesn't color anything.
So I assume that either the if _expression_ or both cond expressions return false.


TIA
Urs


reply via email to

[Prev in Thread] Current Thread [Next in Thread]