\offset Y-offset (was: Distance of a grob from its reference point)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

\offset Y-offset (was: Distance of a grob from its reference point)

Paolo Prete-3
Hello Aaron,

sorry for the (a bit) late reply.

I'm looking at your code and I don't understand what is it intended to do.
You write: "% Test with bracket that is positioned by Y-offset."
but from what I see, the bracket is positioned by both outside-staff-padding and y-offset inside \shiftOttavaBracket.
What do you mean, then?
In addition, please can you write at the beginning of the snippet what you are going to demonstrate? IIUC, what you are going to demonstrate is something that depends on the result of another snippet. Please, can you put all in the same example? Otherwise all becomes too hard to be understood/used.

Thanks,
P

%%%%
\version "2.19.83"

#(define (addRuler color left right)
  (grob-transformer 'stencil (lambda (grob orig)
    (ly:stencil-add
      (grob-interpret-markup grob #{
        \markup \with-dimensions-from \null
        \with-color #color \path #0.1 #`(
          (moveto ,left 0) (lineto ,right 0)
          (moveto ,left 1) (lineto ,right 1)
          (moveto ,left 2) (lineto ,right 2)
        ) #})
      orig))))

notesI = \fixed c''' { \mark "mark" \ottava 1 d8 8 4 \ottava 0 d,2 }
notesII = \fixed c''' { \mark "mark" \ottava 1 a8( 8) 4 \ottava 0 a,2 }

shiftOttavaBracket = #(define-music-function (amount) (number?)
  (let ((half (/ amount 2)))
    #{
      \offset Y-offset #half Staff.OttavaBracket
\override Staff.OttavaBracket.outside-staff-padding = #(+ 0.46 half)
      \override Staff.OttavaBracket.extra-offset = #`(0 . ,half)
    #}))

unshiftOttavaBracket = {
  \revert Staff.OttavaBracket.Y-offset
  \revert Staff.OttavaBracket.outside-staff-padding
  \revert Staff.OttavaBracket.extra-offset
}

{
  \omit Staff.Clef \omit Staff.TimeSignature
  \override Score.RehearsalMark.self-alignment-X = #LEFT

  % Test with bracket that is positioned by Y-offset.
  \override Staff.OttavaBracket.stencil = #(addRuler red -5 10)
  \notesI
  \shiftOttavaBracket 1
  \notesI
  \shiftOttavaBracket 2
  \notesI
  \unshiftOttavaBracket

  % Test with bracket that is positioned by outside-staff.
  \override Staff.OttavaBracket.stencil = #(addRuler blue -5 10)
  \notesII
  \shiftOttavaBracket 1
  \notesII
  \shiftOttavaBracket 2
  \notesII
}
%%%%
Reply | Threaded
Open this post in threaded view
|

Re: \offset Y-offset

Aaron Hill
On 2020-01-19 7:15 am, Paolo Prete wrote:

> I'm looking at your code and I don't understand what is it intended to
> do.
> You write: "% Test with bracket that is positioned by Y-offset."
> but from what I see, the bracket is positioned by both
> outside-staff-padding and y-offset inside \shiftOttavaBracket.
> What do you mean, then?
> In addition, please can you write at the beginning of the snippet what
> you
> are going to demonstrate? IIUC, what you are going to demonstrate is
> something that depends on the result of another snippet. Please, can
> you
> put all in the same example? Otherwise all becomes too hard to be
> understood/used.
It seems that email might not be the best medium of communication for
this.  I am taking a page out of Knuth's handbook with something akin to
literate programming.  Lacking a suitable TeX environment that works
with LilyPond, I chose to do everything in a monolithic LY file.

May you find attached a compiled PDF with its LY source file.  I cannot
promise the LY is the *most* readable, but I have tried to keep things
as organized as possible.  Likewise, I have done a few passes of
proof-reading over the document, but at this point I am unlikely to spot
any typos that remain.  And rather than delay this further, I am sending
out what I have, for better or worse.

Due to the nature of this presentation, there are parts of the LY file
that are not directly relevant to the subject--including a number of
helper functions for overlaying graphics on grobs, as well as a kludgy
solution for including the text of a code snippet in the final document
while also executing it.  Between just reading the PDF by itself and
then along side the LY source, I hope it will not be too difficult to
sort the wheat from the chaff.


-- Aaron Hill

shift-ottava-bracket.ly (35K) Download Attachment
shift-ottava-bracket.pdf (251K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: \offset Y-offset

Schneidy
Wouahoo, nice job Aaron!
Cheers,
Pierre

Le mar. 21 janv. 2020 à 10:30, Aaron Hill <[hidden email]> a écrit :
On 2020-01-19 7:15 am, Paolo Prete wrote:
> I'm looking at your code and I don't understand what is it intended to
> do.
> You write: "% Test with bracket that is positioned by Y-offset."
> but from what I see, the bracket is positioned by both
> outside-staff-padding and y-offset inside \shiftOttavaBracket.
> What do you mean, then?
> In addition, please can you write at the beginning of the snippet what
> you
> are going to demonstrate? IIUC, what you are going to demonstrate is
> something that depends on the result of another snippet. Please, can
> you
> put all in the same example? Otherwise all becomes too hard to be
> understood/used.

It seems that email might not be the best medium of communication for
this.  I am taking a page out of Knuth's handbook with something akin to
literate programming.  Lacking a suitable TeX environment that works
with LilyPond, I chose to do everything in a monolithic LY file.

May you find attached a compiled PDF with its LY source file.  I cannot
promise the LY is the *most* readable, but I have tried to keep things
as organized as possible.  Likewise, I have done a few passes of
proof-reading over the document, but at this point I am unlikely to spot
any typos that remain.  And rather than delay this further, I am sending
out what I have, for better or worse.

Due to the nature of this presentation, there are parts of the LY file
that are not directly relevant to the subject--including a number of
helper functions for overlaying graphics on grobs, as well as a kludgy
solution for including the text of a code snippet in the final document
while also executing it.  Between just reading the PDF by itself and
then along side the LY source, I hope it will not be too difficult to
sort the wheat from the chaff.


-- Aaron Hill
Reply | Threaded
Open this post in threaded view
|

Re: \offset Y-offset

Paolo Prete-3
In reply to this post by Aaron Hill

On Tue, Jan 21, 2020 at 10:30 AM Aaron Hill <[hidden email]> wrote:
On 2020-01-19 7:15 am, Paolo Prete wrote:
> I'm looking at your code and I don't understand what is it intended to
> do.
> You write: "% Test with bracket that is positioned by Y-offset."
> but from what I see, the bracket is positioned by both
> outside-staff-padding and y-offset inside \shiftOttavaBracket.
> What do you mean, then?
> In addition, please can you write at the beginning of the snippet what
> you
> are going to demonstrate? IIUC, what you are going to demonstrate is
> something that depends on the result of another snippet. Please, can
> you
> put all in the same example? Otherwise all becomes too hard to be
> understood/used.

It seems that email might not be the best medium of communication for
this.  I am taking a page out of Knuth's handbook with something akin to
literate programming.  Lacking a suitable TeX environment that works
with LilyPond, I chose to do everything in a monolithic LY file.

May you find attached a compiled PDF with its LY source file. 

Excellent job!
I have to meditate about it before answering. I'll let you know ASAP.

Best,
P
Reply | Threaded
Open this post in threaded view
|

Re: \offset Y-offset

Kieren MacMillan
In reply to this post by Aaron Hill
Aaron,

Brilliant and impressive!

1. You continue to be my patronus. Really amazing work here.

2. Modulo exhaustive testing in real-world situations, you seem (in the final attempt) to have solved the problem completely — bravo!

3. One thing your example/doc strongly reinforces is a long-requested feature (at least for me): the ability to set grob [outside-][staff-]padding parameters *per side* (and of course per axis, if applicable!). Perhaps this is a great place to start a thread/discussion on how that might be implemented globally, and which grobs might be included/excluded in such a global scheme.

Thanks!
Kieren.
________________________________

Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: \offset Y-offset

Carl Sorensen-3
In reply to this post by Aaron Hill


On 1/21/20, 2:29 AM, "Aaron Hill" <[hidden email]> wrote:

    On 2020-01-19 7:15 am, Paolo Prete wrote:
    > I'm looking at your code and I don't understand what is it intended to
    > do.
    > You write: "% Test with bracket that is positioned by Y-offset."
    > but from what I see, the bracket is positioned by both
    > outside-staff-padding and y-offset inside \shiftOttavaBracket.
    > What do you mean, then?
    > In addition, please can you write at the beginning of the snippet what
    > you
    > are going to demonstrate? IIUC, what you are going to demonstrate is
    > something that depends on the result of another snippet. Please, can
    > you
    > put all in the same example? Otherwise all becomes too hard to be
    > understood/used.
   
    It seems that email might not be the best medium of communication for
    this.  I am taking a page out of Knuth's handbook with something akin to
    literate programming.  Lacking a suitable TeX environment that works
    with LilyPond, I chose to do everything in a monolithic LY file.

Aaron, this is a masterpiece!  Not only of coding, but also of explaining the spacing algorithms.

Thanks,

Carl
   


Reply | Threaded
Open this post in threaded view
|

Re: \offset Y-offset

Trevor Bača-2
In reply to this post by Aaron Hill


On Tue, Jan 21, 2020 at 4:30 AM Aaron Hill <[hidden email]> wrote:
On 2020-01-19 7:15 am, Paolo Prete wrote:
> I'm looking at your code and I don't understand what is it intended to
> do.
> You write: "% Test with bracket that is positioned by Y-offset."
> but from what I see, the bracket is positioned by both
> outside-staff-padding and y-offset inside \shiftOttavaBracket.
> What do you mean, then?
> In addition, please can you write at the beginning of the snippet what
> you
> are going to demonstrate? IIUC, what you are going to demonstrate is
> something that depends on the result of another snippet. Please, can
> you
> put all in the same example? Otherwise all becomes too hard to be
> understood/used.

It seems that email might not be the best medium of communication for
this.  I am taking a page out of Knuth's handbook with something akin to
literate programming.  Lacking a suitable TeX environment that works
with LilyPond, I chose to do everything in a monolithic LY file.

May you find attached a compiled PDF with its LY source file.  I cannot
promise the LY is the *most* readable, but I have tried to keep things
as organized as possible.  Likewise, I have done a few passes of
proof-reading over the document, but at this point I am unlikely to spot
any typos that remain.  And rather than delay this further, I am sending
out what I have, for better or worse.

Due to the nature of this presentation, there are parts of the LY file
that are not directly relevant to the subject--including a number of
helper functions for overlaying graphics on grobs, as well as a kludgy
solution for including the text of a code snippet in the final document
while also executing it.  Between just reading the PDF by itself and
then along side the LY source, I hope it will not be too difficult to
sort the wheat from the chaff.

Hi Aaron,

This is such a generous way of communicating your problem-solving approach. Thank you for taking the time to write it up; I learned details of grob spacing that I didn't know I'd been missing for several years.

Trevor.

--