[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: changing symbols used by Measure_grouping_engraver
From: |
Thomas Morley |
Subject: |
Re: changing symbols used by Measure_grouping_engraver |
Date: |
Fri, 3 Aug 2018 13:17:54 +0200 |
2018-08-03 12:25 GMT+02:00 Torsten Hämmerle <address@hidden>:
> Flaming Hakama by Elaine wrote
>> In particular, how to change the symbol used to denote the dotted 8th
>> value
>> in compund time:
>> instead of a triangle, how do I get a vertical bar (or slash)?
>
> Hi Elaine,
>
> The two options "triangle" and "bracket" are pretty much hardcoded.
> But you can set the height (thus squeezing both forms into a vertical line
> when you set height to 0) and thickness (to make this line as thick as you
> like):
>
> \override Staff.MeasureGrouping.height = 0
>
> That way, you'll get a vertical line (unfortunately the bracket will be
> indistinguishable then from the triangle).
>
> But you might define a custom stencil quite easily that sets the height to 0
> if style is #'triangle and then calls the original print stencil.
> In the following example, I've used the original snipped coding as a basis,
> because in your example, there were no brackets at all.
>
> %%%%%%%
> \version "2.19.81"
>
> #(define (custom-grouping-stencil grob)
> (let ((style (ly:grob-property grob 'style)))
> (if (eq? style 'triangle)
> (ly:grob-set-property! grob 'height 0))
> ly:measure-grouping::print))
>
> \score {
> \new Voice \relative c'' {
> \time 9/8
> g8 g d d g g a( bes g) |
> \set Timing.beatStructure = 2,2,2,3
> g8 g d d g g a( bes g) |
> \time 4,5 9/8
> g8 g d d g g a( bes g) |
> \time 5/8
> a4. g4 |
> }
> \layout {
> \context {
> \Staff
> \consists "Measure_grouping_engraver"
> \override MeasureGrouping.stencil = #custom-grouping-stencil
> }
> }
> }
> %%%%%%%
>
> <http://lilypond.1069038.n5.nabble.com/file/t3887/measure-grouping-lines.png>
>
> HTH,
> Torsten
Hi Torsten,
iiuc, this will result in a _horizontal_ line, not vertical. ;)
Here my own attempts: slashes, vertical lines and (just for fun)
tie-style stencils replacing the triangles
\version "2.19.82"
#(define triangle->slash-stencil
(lambda (grob)
(let* ((style (ly:grob-property grob 'style))
(thickness (ly:grob-property grob 'thickness))
(staff-line-thick (ly:staff-symbol-line-thickness grob))
(thick (* thickness staff-line-thick))
(stil (ly:measure-grouping::print grob))
(stil-x-ext (ly:stencil-extent stil X))
(height (ly:grob-property grob 'height)))
(if (eq? style 'triangle)
(make-line-stencil
thick ;width
(car stil-x-ext) ;startx
0 ;starty
(cdr stil-x-ext) ;endx
height ;endy
)
stil))))
#(define triangle->vertical-line-stencil
(lambda (grob)
(let* ((style (ly:grob-property grob 'style))
(thickness (ly:grob-property grob 'thickness))
(staff-line-thick (ly:staff-symbol-line-thickness grob))
(thick (* thickness staff-line-thick))
(height (ly:grob-property grob 'height)))
(if (eq? style 'triangle)
(make-line-stencil
thick ;width
;; 0.5 is my choice, probably catch NoteColumn and take half of
;; its extent
0.5 ;startx
0 ;starty
0.5 ;endx
height ;endy
)
ly:measure-grouping::print))))
#(define triangle->tie-stencil
(lambda (grob)
(let* ((style (ly:grob-property grob 'style))
(stil (ly:measure-grouping::print grob))
(stil-x-ext (ly:stencil-extent stil X))
(length-x (- (cdr stil-x-ext) (car stil-x-ext)))
(height (ly:grob-property grob 'height)))
(if (eq? style 'triangle)
(begin
(ly:grob-set-property! grob 'control-points
(list
(cons 0 0)
(cons (* 1/3 length-x) height)
(cons (* 2/3 length-x) height)
(cons length-x 0)))
(ly:tie::print grob))
ly:measure-grouping::print))))
mus =
\relative c'' {
\time 9/8
g8 g d d g g a( bes g) |
\set Timing.beatStructure = 2,2,2,3
g8 g d d g g a( bes g) |
\time 4,5 9/8
g8 g d d g g a( bes g) |
\time 5/8
a4. g4 |
\set Timing.beatStructure = 3,3,3
}
\score {
\new Voice
{
\override Staff.MeasureGrouping.stencil = #triangle->vertical-line-stencil
\mus
\break
\override Staff.MeasureGrouping.stencil = #triangle->slash-stencil
\mus
\break
\override Staff.MeasureGrouping.stencil = #triangle->tie-stencil
\mus
}
\layout {
\context {
\Staff
\consists "Measure_grouping_engraver"
}
}
}
All the best,
Harm