سؤال

بركة الزنبق يمكن ملاحظات اللون بطريقة تعسفية استخدام

\override NoteHead #'color = #red c

مع اللون الافتراضي أسود. لكنني أحب أن ألوان جميع الملاحظات عن طريق الملعب، بحيث يمكن لأطفالي أن يتعلموا بسهولة أكبر التعرف على الملاحظات بأنها C، D، E، F، ... ترتبط بألوانها الخاصة. ما سبق يتيح لي أن أفعل هذا، ولكنه ضئيل إلى حد ما.

هل هناك اختصار وحدات ماكرو من نوع ما تسمح لي أن أفعل شيئا على غرار:

redc greend bluee

أو حتى الكتابة فوق الألوان الافتراضية لكل ملاحظة عن طريق الملعب حتى أتمكن من القيام به ببساطة:

c d e

ولدي كل منهم لديهم لون مختلف؟

هل كانت مفيدة؟

المحلول

هناك مثال لهذا في مقتطفات:

%Association list of pitches to colors.
#(define color-mapping
  (list
    (cons (ly:make-pitch 0 0 0) (x11-color 'red))
    (cons (ly:make-pitch 0 0 1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 1 -1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 2 0) (x11-color 'red))
    (cons (ly:make-pitch 0 2 1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 3 -1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 3 0) (x11-color 'green))
    (cons (ly:make-pitch 0 4 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 5 0) (x11-color 'green))
    (cons (ly:make-pitch 0 5 -1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 6 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 1 0) (x11-color 'blue))
    (cons (ly:make-pitch 0 3 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 6 -1/2) (x11-color 'blue))
    ))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
  (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
  (let ((color (assoc pitch color-mapping pitch-equals?)))
    (if color
      (cdr color))))

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

\score {
  \new Staff \relative c' {
    \override NoteHead #'color = #color-notehead
    c8 b d dis ees f g aes
  }
}

Sample image

نصائح أخرى

هناك سؤال من الممكن تلوين رؤساء الملاحظات اعتمادا على أرضهم؟ في ال Lilypond Snippet مستودع. وبعد لقد حصلت الاجابة من خلال النقر على Stave.

حسنا، للكتاب دورة لوحة المفاتيح كيد - كتاب رقم 1 اشتريت في وقت سابق من هذا العام في كامبريدج، لدي الآن ترميز اللون هذا:

#(define color-mapping
  (list
    (cons (ly:make-pitch 0 0 0) (x11-color 'magenta))
    (cons (ly:make-pitch 0 1 -1/2) (x11-color 'grey))
    (cons (ly:make-pitch 0 1 0) (x11-color 'grey))
    (cons (ly:make-pitch 0 1 1/2) (x11-color 'grey))
    (cons (ly:make-pitch 0 2 0) (x11-color 'red))
    (cons (ly:make-pitch 0 2 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 3 -1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 3 0) (x11-color 'green))
    (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 0) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 0) (x11-color 'yellow))
    (cons (ly:make-pitch 0 5 -1/2) (x11-color 'yellow))
    (cons (ly:make-pitch 0 5 1/2) (x11-color 'yellow))
    (cons (ly:make-pitch 0 6 1/2) (x11-color 'purple))
    (cons (ly:make-pitch 0 6 0) (x11-color 'purple))
    (cons (ly:make-pitch 0 6 -1/2) (x11-color 'purple))))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top