Deutsches Lilypond Forum (Archiv)
Allgemein => Fragen zu Funktionen => Thema gestartet von: erich am Freitag, 7. März 2014, 15:09
-
Moin
Ich möchte immer dieselbe Notenlinie rot einfärben.
Das Snippet von Neil Puttock ist mir bekannt und es tut auch, was ich will.
ich hätte dieses Snippet gerne vereinfacht, so dass immer dieselbe Linie rot gezeichnet wird;
ich habe Schwierigkeiten, das Snippet zu verstehen, um selbst die Vereinfachung vorzunehmen.
Ist einer klüger als ich und kann mir helfen
Erich
-
Wenn du mir nen Link zu dem Snippet gibst (bzw. es in eine Datei im Anhang deiner Antwort packst), kann ich mir das anschauen, ja.
Am besten mit nem kompilierbaren Minimalbeispiel und Angabe deiner LilyPond-Versionsnummer.
-
Hallo Erich,
wie schon von fugenkomponist geschrieben, sind hier kleine kompilierbare Beispiele üblich, die dann kopiert und nach den Wünschen des Themenstarters geändert werden können. Das spart Zeit und Erklärungen.
Die Suche hier im Forum hilft auch:
https://liarchiv.joonet.de/index.php?topic=559.msg3052#msg3052
Soweit ich deiner Frage entnehmen kann, ist das evtl. eine Lösung für dich:
\version "2.18.0"
#(define-public ((color-staff-lines . rest) grob)
(define (index-cell cell dir)
(if (equal? dir RIGHT)
(cdr cell)
(car cell)))
(define (index-set-cell! x dir val)
(case dir
((-1) (set-car! x val))
((1) (set-cdr! x val))))
(let* ((common (ly:grob-system grob))
(span-points '(0 . 0))
(thickness (* (ly:grob-property grob 'thickness 1.0)
(ly:output-def-lookup (ly:grob-layout grob) 'line-thickness)))
(width (ly:grob-property grob 'width))
(line-positions (ly:grob-property grob 'line-positions))
(staff-space (ly:grob-property grob 'staff-space 1))
(line-stencil #f)
(total-lines empty-stencil)
;; use a local copy of colors list, since
;; stencil creation mutates list
(colors rest))
(for-each
(lambda (dir)
(if (and (= dir RIGHT)
(number? width))
(set-cdr! span-points width)
(let* ((bound (ly:spanner-bound grob dir))
(bound-ext (ly:grob-extent bound bound X)))
(index-set-cell! span-points dir
(ly:grob-relative-coordinate bound common X))
(if (and (not (ly:item-break-dir bound))
(not (interval-empty? bound-ext)))
(index-set-cell! span-points dir
(+ (index-cell span-points dir)
(index-cell bound-ext dir))))))
(index-set-cell! span-points dir (- (index-cell span-points dir)
(* dir thickness 0.5))))
(list LEFT RIGHT))
(set! span-points
(coord-translate span-points
(- (ly:grob-relative-coordinate grob common X))))
(set! line-stencil
(make-line-stencil thickness (car span-points) 0 (cdr span-points) 0))
(if (pair? line-positions)
(for-each (lambda (position)
(let ((color (if (pair? colors)
(car colors)
#f)))
(set! total-lines
(ly:stencil-add
total-lines
(ly:stencil-translate-axis
(if (color? color)
(ly:stencil-in-color line-stencil
(first color)
(second color)
(third color))
line-stencil)
(* position staff-space 0.5) Y)))
(and (pair? colors)
(set! colors (cdr colors)))))
line-positions)
(let* ((line-count (ly:grob-property grob 'line-count 5))
(height (* (1- line-count) (/ staff-space 2))))
(do ((i 0 (1+ i)))
((= i line-count))
(let ((color (if (and (pair? colors)
(> (length colors) i))
(list-ref colors i)
#f)))
(set! total-lines (ly:stencil-add
total-lines
(ly:stencil-translate-axis
(if (color? color)
(ly:stencil-in-color line-stencil
(first color)
(second color)
(third color))
line-stencil)
(- height (* i staff-space)) Y)))))))
total-lines))
\relative c' {
\override Staff.StaffSymbol #'stencil = #(color-staff-lines #f #f #f red)
c4 d e f
}
Kurze Erklärung dazu: Es ist genau das Snippet von Puttock, also habe ich alle Definitionen am Anfang stehen gelassen. Mit dieser Zeile gibst du die Notenlinie an, die gefärbt werden soll:
\override Staff.StaffSymbol #'stencil = #(color-staff-lines #f #f #f red)
#f #f #f bedeutet, dass (von oben gezählt) die ersten drei Linien nicht gefärbt werden. Wenn du also z.B. die mittlere Linie färben willst, musst du das schreiben:
\override Staff.StaffSymbol #'stencil = #(color-staff-lines #f #f red)
Gruß von Trulli
-
Hallo,
allerdings gibt es Bedenken dieses Snippets wegen.
http://lists.gnu.org/archive/html/lilypond-user/2013-05/msg00714.html (http://lists.gnu.org/archive/html/lilypond-user/2013-05/msg00714.html) ff
Aber keine Lösung dafür. :(
Gruß,
Harm
-
Moin,
@fugenkomponist: Ich hätte die Nummer zum Snippet angeben sollen: LSR878.
Ich hatte diese Konvention noch nicht internalisiert; hier ist Besserung in Sicht.
@trulli: Danke für Deine Mühe; genau das hatte ich mit
Das Snippet von Neil Puttock ist mir bekannt und es tut auch, was ich will.
ausdrücken wollen.
@Harm: Ich dachte an eine parameterlose color-staff-line Funktion (also line statt lines),
die man aus dem LSR878-Code durch Vereinfachung gewinnt.
@all: vielen Dank für Eure Mühe