lilypond-user
[Top][All Lists]

Re: Distance of a grob from its reference point

 From: Aaron Hill Subject: Re: Distance of a grob from its reference point Date: Wed, 15 Jan 2020 15:45:46 -0800 User-agent: Roundcube Webmail/1.3.8

```On 2020-01-15 1:57 pm, Paolo Prete wrote:
```
```I quote Carl's words:

```
"So offset applies to the *estimated* position, and then the spacing engine works on the offset+estimated postion and ends up putting things where it
```thinks they belong"

```
I checked that with the examples made before and it seems absolutely true.
```
```
Then: you have to offset an estimated position. How could you do that if
```you don't know this estimated position?
```
```
```
\offset is a simple tool that merely adds a number to a number. Well to be fair, it has some complexity behind the scenes as it can handle offsetting numbers, pairs of numbers, and lists of numbers. The problem is unlikely with \offset; rather, it is the property you are modifying not having the final say.
```
```
Consider: Y-offset is a desired distance between the reference points of a grob and its parent. OttavaBrackets use a procedure to determine this initial desired distance. And because Y-axis spacing issues are tricky, the unpure-pure container system exists to assist. The pure value is an estimate used before line breaking, and the unpure value consulted after line breaking.
```
```
But even with the issues of unpure-pure containers aside, Y-offset is not the sole arbiter of positioning a bracket. You can see this here:
```
%%%%
\version "2.19.83"

visualizeYOffset = #(define-music-function (grob-path) (symbol-list?)
(define (proc grob)
(let* ((orig (ly:grob-property grob 'stencil))
(yoff (ly:grob-property grob 'Y-offset))
(y (- yoff))
(sten (grob-interpret-markup grob #{ \markup
\with-dimensions-from \stencil #orig
\overlay {
\stencil #orig
\with-color #red \path #0.1 #`(
(moveto -1 0) (lineto 1 0)
(moveto 0 0) (lineto 0 ,y)
(moveto -0.4 -1) (lineto 0 0) (lineto 0.4 -1)
(moveto -1 ,y) (lineto 1 ,y))
\translate #(cons -0.8 (/ y 2))
\general-align #X #RIGHT \vcenter \rotate #90
\with-color #red \normal-text \fontsize #-6
\line { Y-offset: #(format #f "~,3f" yoff) }
} #})))
(ly:grob-set-property! grob 'layer 1000)
(ly:grob-set-property! grob 'stencil sten)))
#{ \override \$grob-path .after-line-breaking = #proc #})

notes = \fixed c''' { \ottava 1 a8( 8) \ottava 0 a,4 }

{
\visualizeYOffset Staff.OttavaBracket

\notes
\once \offset Y-offset 0.4 Staff.OttavaBracket
\notes
\once \override Staff.OttavaBracket.Y-offset = 6
\notes
\once \offset Y-offset 1.6 Staff.OttavaBracket
\notes
\once \override Staff.OttavaBracket.outside-staff-padding = 1
\notes
}
%%%%

```
The slur exerts influence on the final bracket position that goes beyond the bracket's Y-offset. The first \offset is not enough to overcome this; but the explicit value and larger \offset are enough to show that modifying Y-offset can work.
```
```
The alternate approach would be to not use Y-offset at all but rather control something like outside-staff-padding, as shown in the final example.
```

-- Aaron Hill```

ottavabracket-y-offset.cropped.png
Description: PNG image

reply via email to