lilypond-user
[Top][All Lists]
Advanced

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

Re: Color script for Note Colors, Code and instructions for trying it ou


From: darkijah
Subject: Re: Color script for Note Colors, Code and instructions for trying it out and note letters for help for beginners - and if anyone could explain some code for me as well.
Date: Fri, 14 May 2021 09:44:07 +0200
User-agent: Gigahost Webmail

Working file for now with all active for a trial, very quick to test out :), just copy and paste and run:

\version "2.22.1"
%{Rainbow Notes Colors for Learners depending on Pitch or names,
Low to highest vibration: C=Red D=Orange E=Yellow F=Green G=Lightblue A=Blue B=Violet the function used in this example even makes it possible to distinguish enharmonics.%}

%Association list of pitches to colors ♭C# ♭D# ♭E# ♭F# ♭G# ♭A# ♭B#:
#(define color-mapping(list
(cons (ly:make-pitch 0 0 FLAT) (x11-color 'red3))
(cons (ly:make-pitch 0 0 NATURAL) (x11-color 'red3))
(cons (ly:make-pitch 0 0 SHARP) (x11-color 'red3))

(cons (ly:make-pitch 0 1 FLAT) (x11-color 'orange3))
(cons (ly:make-pitch 0 1 NATURAL) (x11-color 'orange3))
(cons (ly:make-pitch 0 1 SHARP) (x11-color 'orange3))

(cons (ly:make-pitch 0 2 FLAT) (x11-color 'yellow3))
(cons (ly:make-pitch 0 2 NATURAL) (x11-color 'yellow3))
(cons (ly:make-pitch 0 2 SHARP) (x11-color 'yellow3))

(cons (ly:make-pitch 0 3 FLAT) (x11-color 'green4))
(cons (ly:make-pitch 0 3 NATURAL) (x11-color 'green4))
(cons (ly:make-pitch 0 3 SHARP) (x11-color 'green4))

(cons (ly:make-pitch 0 4 FLAT) (x11-color 'lightblue3))
(cons (ly:make-pitch 0 4 NATURAL) (x11-color 'lightblue3))
(cons (ly:make-pitch 0 4 SHARP) (x11-color 'lightblue3))

(cons (ly:make-pitch 0 5 FLAT) (x11-color 'darkblue))
(cons (ly:make-pitch 0 5 NATURAL) (x11-color 'darkblue))
(cons (ly:make-pitch 0 5 SHARP) (x11-color 'darkblue))

(cons (ly:make-pitch 0 6 FLAT) (x11-color 'VioletRed4))
(cons (ly:make-pitch 0 6 NATURAL) (x11-color 'VioletRed4))
(cons (ly:make-pitch 0 6 SHARP) (x11-color 'VioletRed4))))

%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 (event-cause grob) 'pitch)))

% \override Beam.color = #(x11-color "medium turquoise")
% \override Accidental.color = #(rgb-color 1 0.3 0.3)
% \override NoteHead.color = #(rgb-color 0.5 0.5 0.5)
% \override Stem.color = #(rgb-color 0.8 0.8 0)


\score { \new Staff \relative d' { \key d \major \time 3/4
\override NoteHead.color = #color-notehead
ces c cis | des d dis | ees e eis | fes f fis | ges g gis | aes a ais | bes b bis |
}}

\score { \new Staff \relative d' { \key d \major \time 3/4 \easyHeadsOn
\override NoteHead.color = #color-notehead
ces c cis | des d dis | ees e eis | fes f fis | ges g gis | aes a ais | bes b bis |
}}

\relative { \time 22/4
  \override NoteHead.color = #color-notehead

  c d e f g a b c d e f g a b c d e f g a b c
}

\relative { \time 22/4 \easyHeadsOn
  \override NoteHead.color = #color-notehead

  c d e f g a b c d e f g a b c d e f g a b c
}

Attachment: 186495072_10159633602533754_6242248972998875857_n.jpg
Description: JPEG image


reply via email to

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