[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Center-align a score
From: |
Kieren MacMillan |
Subject: |
Re: Center-align a score |
Date: |
Thu, 4 May 2017 13:04:27 -0400 |
Hi Hendrik,
> Thomas, I have no clue what you did there
Magic. =)
> how to get the center-alignment activated only for a single score
See snippet, below.
Hope this helps!
Kieren.
%% SNIPPET BEGINS
\version "2.19.59"
\paper {
ragged-right = ##t
indent = 0
}
centerLines =
\override NonMusicalPaperColumn.after-line-breaking =
#(lambda (grob)
(if (eqv? (ly:item-break-dir grob) 1) ; line beginning
(let* ((sys (ly:grob-system grob))
;; filter for StaffSymbol-grobs
(staff-symbols
(filter
(lambda (grob)
(grob::has-interface grob 'staff-symbol-interface))
(ly:grob-array->list (ly:grob-object sys 'all-elements))))
;; StaffSymbols may start/end during same system
;; Best bet is to look for the most left/right start/end-coord
(min-max
(lambda (list-of-pairs)
(cons
(reduce min +inf.0 (map car list-of-pairs))
(reduce max -inf.0 (map cdr list-of-pairs)))))
(line-width
(interval-length
(min-max
(map
(lambda (g) (ly:grob-property g 'X-extent))
staff-symbols))))
(layout (ly:grob-layout grob))
(line-full-width (ly:output-def-lookup layout 'line-width)))
(ly:grob-set-nested-property! grob
'(line-break-system-details X-offset)
(/ (- line-full-width line-width) 2)))))
\layout {
\context {
\Staff
\override StaffSymbol.line-count = #1
\omit TimeSignature
\omit Clef
}
\context {
\Score
\override BarNumber.stencil = ##f
}
}
theNotes = {
b'4 b' b'2 \break
b'4 b' b'2 \break
b'4 b' b' b' b' b' b'2
}
theLyrics = \lyricmode {
Häns -- chen klein
ging al -- lein
in die wei -- te Welt hi -- nein
}
\score {
<<
\new Staff \theNotes
\addlyrics { \theLyrics }
>>
}
\score {
<<
\new Staff \theNotes
\addlyrics { \theLyrics }
>>
\layout {
\context {
\Score
\centerLines
}
}
}
\score {
<<
\new Staff \theNotes
\addlyrics { \theLyrics }
>>
}
%% SNIPPET ENDS
________________________________
Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: address@hidden