31
Fragen zu Funktionen / Re: Abstände von Ankerpunkten in vertikaler Richtung finden
« Letzter Beitrag von xr am Freitag, 17. März 2017, 11:15 »Um die Abstände der Ankerpunkte zu finden, habe jetzt folgenden Code:
Eingebunden wird der Code mit:
Dies ist jetzt ein Auszug aus dem kompletten Beispiel in dem anderen Thread, den ich schon angesprochen hatte.
Das komplette Beispiel findet sich hier:
https://github.com/XRoemer/Lilypond/tree/master/Custom_Slurs
Und hier können alle Dateien als zip. heruntergeladen werden:
https://github.com/XRoemer/Lilypond
Gruß,
Xaver
Code: [Auswählen]
#(define counter-va-lines 1)
#(define ht-va-distances (make-hash-table))
#(define (get-slur-extents layout pages)
;; This method has to be the first to be executed. It starts at the end
;; of the first compilation pass. Another pass is neccessary to use the calculated values.
;; It iterates over pages/system-lines/VerticalAlignment/VerticalAxisGroup.
;; Writes the distance between each VerticalAxisGroup
;; and the system baseline to the hash table ht-va-distances.
;; Key is the number of the system line, counted by
;; counter-va-lines
(for-each (lambda (page)
(for-each (lambda (line)
(let* (
(sys-grob (ly:prob-property line 'system-grob))
)
(if (not (equal? sys-grob '()))
(begin
(let* (
(vertAlign (ly:system::get-vertical-alignment sys-grob))
(va-groups (ly:grob-array->list (ly:grob-object vertAlign 'elements)))
(tmp '())
)
(for-each
(lambda (group)
;; a VAGroup with no elements (e.g. no lyrics) will turn
;; to a spanner grob. As it has no properties, grob::name
;; returns false.
(if (grob::name group)
;; calculate relative position between
;; system baseline and VAGroup
(set! tmp (append tmp (list
(ly:grob-relative-coordinate group sys-grob Y))))
(set! tmp (append tmp '(0 0)))
)
)
va-groups
)
(hash-set! ht-va-distances
(number->string counter-va-lines)
tmp)
(set! counter-va-lines (1+ counter-va-lines))
)
)
)
))
(ly:prob-property page 'lines)
))
pages
)
) Eingebunden wird der Code mit:
Code: [Auswählen]
\paper {
#(define (page-post-process layout pages)
(get-slur-extents layout pages))
}
Dies ist jetzt ein Auszug aus dem kompletten Beispiel in dem anderen Thread, den ich schon angesprochen hatte.
Das komplette Beispiel findet sich hier:
https://github.com/XRoemer/Lilypond/tree/master/Custom_Slurs
Und hier können alle Dateien als zip. heruntergeladen werden:
https://github.com/XRoemer/Lilypond
Gruß,
Xaver
Neueste Beiträge
).