Le 18/05/2021 à 16:38, Lukas-Fabian Moser a écrit :
Seeing the discussion on coloured lyrics, colour this and that, I realized that for some parts I do change the Background Colour of the clefs maually (using a standard ofice yellow marking (grease) pencil each time after an update print. The purpose is to have a fast recognition point for the eyes to jump to the next line and/or page.How about:Improved version that only tweaks the stencil after-line-breaking: \version "2.19" #(define (positive-number? x) (and (number? x) (positive? x))) markerPen = #(define-music-function (X-padding Y-padding grob-path) ((positive-number? 0.5) (positive-number? 0) key-list?) #{ \override #grob-path .layer = -1 \override #grob-path .after-line-breaking = #(lambda (grob) (let* ((original (ly:grob-property grob 'stencil)) (X-ext (ly:stencil-extent original X)) (Y-ext (ly:stencil-extent original Y))) (ly:grob-set-property! grob 'stencil (ly:stencil-add (ly:make-stencil (ly:stencil-expr (stencil-with-color (ly:round-filled-box (interval-widen X-ext X-padding) (interval-widen Y-ext Y-padding) 1) yellow)) empty-interval empty-interval) original)))) #}) \new Staff \with { \markerPen Clef } \relative { c'4 d \once\markerPen 0.5 0.5 Accidental es fis \once \markerPen Staff.BarLine g \markerPen 0.5 0.5 NoteHead g a }While this does not solve the problem of the marking affecting inter-system spacing, at least it now works fine for accidentals.
How about a separate grob with engraver? Try the attached.
Is there also a possibility to automatically colour the background in Lilypond, or is there a feature wishlist to which I could add this
You could add it at https://gitlab.com/lilypond/lilypond/-/issues
A variant marking a complete voice in another background colour or only the clef(s) would probably also do.
I have been working on something pretty much like that lately.
Is there a way to make a color glow from an image? I actually need something of that sort for the colored notes.
With the attached code, \override TheGrob.highlight-me = ##t \override TheGrob.highlight-details.stencil = #ly:text-interface::print\override TheGrob.highlight-details.text = \markup \epsfile #X #2.0 "path/to/an/EPS/image.eps"
(Adjust the 2.0 to the desired width.) Best, Jean
\version "2.23.3"
#(define (define-grob! grob-name grob-entry)
(let* ((meta-entry (assoc-get 'meta grob-entry))
(class (assoc-get 'class meta-entry))
(ifaces-entry (assoc-get 'interfaces meta-entry)))
(set-object-property! grob-name 'translation-type? ly:grob-properties?)
(set-object-property! grob-name 'is-grob? #t)
(set! ifaces-entry (append (case class
((Item) '(item-interface))
((Spanner) '(spanner-interface))
((Paper_column) '((item-interface
paper-column-interface)))
((System) '((system-interface
spanner-interface)))
(else '(unknown-interface)))
ifaces-entry))
(set! ifaces-entry (uniq-list (sort ifaces-entry symbol<?)))
(set! ifaces-entry (cons 'grob-interface ifaces-entry))
(set! meta-entry (assoc-set! meta-entry 'name grob-name))
(set! meta-entry (assoc-set! meta-entry 'interfaces
ifaces-entry))
(set! grob-entry (assoc-set! grob-entry 'meta meta-entry))
(set! all-grob-descriptions
(cons (cons grob-name grob-entry)
all-grob-descriptions))))
#(set-object-property! 'X-padding 'backend-type? number?)
#(set-object-property! 'Y-padding 'backend-type? number?)
#(set-object-property! 'highlight-me 'backend-type? boolean?)
#(set-object-property! 'highlight-details 'backend-type? list?)
#(set-object-property! 'blot 'backend-type? number?)
#(define (grob-highlight::print grob)
(let ((parent (ly:grob-parent grob X)))
(if (grob::is-live? parent)
(let* ((X-extent (ly:grob-extent parent parent X))
(Y-extent (ly:grob-extent parent parent Y))
(X-padding (ly:grob-property grob 'X-padding 0))
(Y-padding (ly:grob-property grob 'Y-padding 0))
(blot (ly:grob-property grob 'blot 0)))
(ly:round-filled-box
(interval-widen X-extent X-padding)
(interval-widen Y-extent Y-padding)
blot)))))
#(define-grob!
'GrobHighlight
`((layer . -10)
(stencil . ,grob-highlight::print)
(X-extent . #f)
(Y-extent . #f)
(meta . ((class . Item)
(interfaces . ())))))
#(define (Grob_highlight_engraver context)
(let ((grobs '()))
(make-engraver
(acknowledgers
((grob-interface engraver grob source-engraver)
(if (eq? #t (ly:grob-property grob 'highlight-me))
(set! grobs (cons grob grobs)))))
((process-acknowledged engraver)
(for-each
(lambda (grob)
(let ((highlight (ly:engraver-make-grob engraver 'GrobHighlight grob)))
(ly:grob-set-parent! highlight X grob)
(ly:grob-set-parent! highlight Y grob)
(for-each
(lambda (entry)
(ly:grob-set-property! highlight
(car entry)
(cdr entry)))
(ly:grob-property grob 'highlight-details))))
grobs)
(set! grobs '())))))
\layout {
\context {
\Global
\grobdescriptions #all-grob-descriptions
}
\context {
\Score
\consists #Grob_highlight_engraver
}
}
\new Staff \with {
\override Clef.highlight-me = ##t
\override Clef.highlight-details.blot = 1
\override Clef.highlight-details.color = "lightblue"
\override Clef.highlight-details.X-padding = 0.2
\override Clef.highlight-details.Y-padding = 1
}
\relative {
c'4 d
\tweak Accidental.highlight-me ##t \tweak Accidental.highlight-details.color "red"
es fis
\break
g a
}
marker.pdf
Description: Adobe PDF document
