[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Colored note heads with black outline
From: |
Paul Morris |
Subject: |
Re: Colored note heads with black outline |
Date: |
Tue, 8 Oct 2013 18:36:24 -0700 (PDT) |
Onno Zweers wrote
> One question though. I intend to apply this effect to many different
> lilypond scores. Currently I include a stylesheet.ly from all my
> Lilypond files to produce the colors. It would be great if I could just
> add some code to my stylesheet to get this outline effect, instead of
> overriding individual note heads. Would that be possible?
Hi Onno,
The code below should do what you want. I combined Pierre's outlined note
heads with some code I use to automatically override note head stencils
based on their pitch. It creates outlines around all note heads regardless
of their color, and it requires LilyPond 2.17.
HTH,
-Paul
%%% BEGIN SNIPPET %%%
\version "2.17"
coloredNoteHeads =
#(lambda (grob)
(let* ((fsz (ly:grob-property grob 'font-size 0.0))
(mult (magstep fsz))
(stl '())
(dur-log (ly:grob-property grob 'duration-log))
(pitch (ly:event-property (event-cause grob) 'pitch))
(note-name (ly:pitch-notename pitch))
(clr (case note-name
((0) red) ;; C
((1) blue) ;; D
((2) yellow) ;; E
((3) red) ;; F
((4) blue) ;; G
((5) yellow) ;; A
((6) green)))) ;; B
;; just for dev work
;; (display dur-log) (newline)
;; (display note-name) (newline)
(set! stl
(cond
;; quarter notes and smaller
((> dur-log 1)
(grob-interpret-markup grob
#{ \markup {
\combine
\musicglyph #"noteheads.s2"
\translate-scaled #'(0.07 . 0.01)
\scale #'(1.01 . 0.98)
\rotate #'2
\magnify # 0.9 \with-color #clr
\musicglyph #"noteheads.s2"
} #} ))
;; half notes
((= dur-log 1)
(grob-interpret-markup grob
#{ \markup {
\combine
\translate-scaled #'(0.11 . -0.01)
\scale #'(1 . 0.82)
\rotate #'7
\magnify # 0.85
\musicglyph #"noteheads.s1"
\combine
\musicglyph #"noteheads.s1"
\translate-scaled #'(0.07 . 0)
\scale #'(1.02 . 0.98)
\rotate #'2
\magnify # 0.9 \with-color #clr
\musicglyph #"noteheads.s1"
} #} ))
;; whole notes
((< dur-log 1)
(grob-interpret-markup grob
#{ \markup {
\combine
\translate-scaled #'(0.2 . 0)
\magnify # 0.8
\musicglyph #"noteheads.s0"
\combine
\musicglyph #"noteheads.s0"
\translate-scaled #'(0.08 . 0)
\scale #'(1.03 . 1)
\magnify # 0.9 \with-color #clr
\musicglyph #"noteheads.s0"
} #}))))
(set! (ly:grob-property grob 'stencil)
(ly:stencil-scale stl mult mult))))
music =
\relative f' {
c4 d e f g a b c d e f g a b c d
c,,2 d e f g a b c d e f g a b c d
c,,1 d e f g a b c d e f g a b c
}
\new Staff \with
{ \override NoteHead.before-line-breaking = \coloredNoteHeads }
{ \music }
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/Colored-note-heads-with-black-outline-tp151821p152011.html
Sent from the User mailing list archive at Nabble.com.