lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature requests: scalable \shape values; (stem) for \shapeII


From: Martín Rincón Botero
Subject: Re: feature requests: scalable \shape values; (stem) for \shapeII
Date: Sun, 11 Oct 2020 10:13:36 +0200

Dear Thomas,

sorry for not having provided examples myself of what doesn’t scale. I haven’t had the time for that yet. However, your explanation seems to be right. I definitely have to use smaller values for smaller font sizes. I was planning to collect a few examples from the viola concerto I’m working on. But your example shows what I meant! Curves can look substantially different with the same values with different font sizes. 

Thank you for that code!!! I can see now that values seem to scale with it. I’ll have to try it myself. Perhaps that could be the fix for the recently opened issue a couple of messages above in this thread? 

Regards,
Martín.

www.martinrinconbotero.com
On 11. Oct 2020, 10:04 +0200, Thomas Morley <thomasmorley65@gmail.com>, wrote:
Am Mi., 7. Okt. 2020 um 10:35 Uhr schrieb Martín Rincón Botero
<martinrinconbotero@gmail.com>:

Now that we’ve been talking about \shape and \shapeII, I would like to ask if it’s possible that values put for \shape(II) could scale according to staff size. Whenever I have a smaller staff, whatever values work for a 20 points staff are too much for smaller staves (either with a smaller font size or with \magnify). It would be great, from a user perspective, that a (0 . 1) value would produce a similar/proportional result no matter the size of the staff, instead of being always in a different “scale” every time you have different staff sizes (so that you have to put smaller values for smaller staves). That would also be useful if you decide later to increase or decrease the font size used.

Hi Martín,

\shape adds your settings to the calculated control-points of the curve.
Though, those control-points are calculated differently depending on
staff-space.
Look at the example below, you will notice the default control-points
are always different.
In the attached image I let print the second and third control-point.

\layout {
\context {
\Voice
\override NoteHead.stencil = #point-stencil
}
}

mus = { b'1_~ b'1 }

\new Staff \with { \magnifyStaff #4 } \mus
\new Staff \with { \magnifyStaff #1 } \mus
\new Staff \with { \magnifyStaff #1/4 } \mus

This means \shape always gets different control-points to work with,
thus the result will never be consistent even for scaled
offset-values.

Nevertheless, it's not too hard to code a shape-version, which will
scale it's offset-values according to current staff-space:

\version "2.20.0"

shape-h =
#(define-music-function (offsets item)
(list? key-list-or-music?)
(_i "Offset control-points of @var{item} by @var{offsets}. The
argument is a list of number pairs or list of such lists. Each
element of a pair represents an offset to one of the coordinates of a
control-point. If @var{item} is a string, the result is
@code{\\once\\override} for the specified grob type. If @var{item} is
a music _expression_, the result is the same music _expression_ with an
appropriate tweak applied.")
(define (shape-curve grob coords)
(let* ((orig (ly:grob-original grob))
(siblings (if (ly:spanner? grob)
(ly:spanner-broken-into orig) '()))
(total-found (length siblings))
(staff-space (ly:staff-symbol-staff-space grob))
(offsets
(map
(lambda (offset)
(if (number-pair? offset)
(cons (car offset) (* (cdr offset) staff-space))
offset))
offsets)))
(define (offset-control-points offsets)
(if (null? offsets)
coords
(map coord-translate coords offsets)))

(define (helper sibs offs)
(if (pair? offs)
(if (eq? (car sibs) grob)
(offset-control-points (car offs))
(helper (cdr sibs) (cdr offs)))
coords))

;; we work with lists of lists
(if (or (null? offsets)
(not (list? (car offsets))))
(set! offsets (list offsets)))

(if (>= total-found 2)
(helper siblings offsets)
(offset-control-points (car offsets)))))

(once (propertyTweak 'control-points
(grob-transformer 'control-points shape-curve)
item)))

\layout {
\context {
\Voice
\override NoteHead.stencil = #point-stencil
}
}

mus = { b'1 \shape-h #'((0 . 1) (0 . 0) (0 . 0) (0 . 0)) _~ b'1 }

\new Staff \with { \magnifyStaff #4 } \mus
\new Staff \with { \magnifyStaff #1 } \mus
\new Staff \with { \magnifyStaff #1/4 } \mus

See second image.

Cheers,
Harm

reply via email to

[Prev in Thread] Current Thread [Next in Thread]