lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coloring noteheads different depending on parts


From: takmi ikeda
Subject: Re: coloring noteheads different depending on parts
Date: Sat, 20 Apr 2013 10:05:27 +0900

oops. Variable name is my silly mistake. I couldn't understand list
structure of scheme, difference between #(a. b) #(a b) . Thank you so
much!

\version "2.16.0"

%%% fixed code

#(define-public ((color-notehead nnn) grob)

   (define color-mapping
     (vector
      (list
       (cons (ly:make-pitch 0 0 0) (rgb-color 1 .5 0))
       (cons (ly:make-pitch 0 4 0) (rgb-color .3 .7 0))
       )
      (list
       (cons (ly:make-pitch 0 1 0) (rgb-color 1 0 1))
       (cons (ly:make-pitch 0 5 0) (rgb-color .5 0 1))
       )
      )
     )

   (define (pitch-to-color pitch)
     (let*
      (
       (vvv (vector-ref color-mapping nnn))
       (ccc (assoc pitch vvv))
       )
      (if ccc
          (cdr ccc))
      )
     )

   (pitch-to-color
    (ly:event-property (event-cause grob) 'pitch))
   )

aaa = \relative c' { c8 d e f g a b c }

\score {
  <<
    \new Staff <<
      \override Staff.NoteHead #'color = #(color-notehead 0)
      \aaa
    >>
    \new Staff <<
      \override Staff.NoteHead #'color = #(color-notehead 1)
      \aaa
    >>
  >>
}



2013/4/19 David Kastrup <address@hidden>:
> takmi ikeda <address@hidden> writes:
>
>> i'd like to change coloring by argument. have you any idea?
>>
>> \version "2.16.0"
>>
>> #(define-public ((color-notehead . nnn) grob)
> (define-public ((color-notehead num) grob)
>
>
>>        (vvv (vector-ref color-mapping num)) ;it does not works.
>
> Hardly surprising.  Wrong variable name.  Even if you were write, the
> define-public used nnn as a rest argument due to the . before it, so any
> number would have gotten wrapped into a list.
>
> --
> David Kastrup
>
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user



reply via email to

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