lilypond-user
[Top][All Lists]
Advanced

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

Re: Draw a line on the X reference point of a grob


From: Aaron Hill
Subject: Re: Draw a line on the X reference point of a grob
Date: Sun, 19 Jan 2020 12:52:11 -0800
User-agent: Roundcube Webmail/1.3.8

On 2020-01-19 8:17 am, Paolo Prete wrote:
Hello. IIUC, the reference point for the X-offset property (or any other x-shifting property that preserves the avoid-collisions algo) is on the X-
parent grob of the grob I want to modify.

Is there a way to draw a line on this grob, so that I can visually well see
the distance that I'm going to modify?
I tried to use the ly:grob-parent function, but there's obviously some
error in the below code, as it doesn't show anything:

%%%%%%%%%%%%%%%

{
\tweak DynamicText.after-line-breaking
#(lambda (grob)
(let* ((grob-x-parent (ly:grob-parent grob 0)))
    (ly:grob-set-property! grob-x-parent 'stencil
#{ \markup { \override #'(thickness . 3) \draw-line #'(0 . 3) } #})))
c'\mf
}

There are two issues, although one is hiding due to the other.

The \tweak command needs to be used immediately before whatever you are tweaking. Since you want to modify the \mf, you must use the post-event version of \tweak. Consider the following uses (and misuse) of \tweak:

%%%%
\version "2.18.2"
{
  % This will \tweak the NoteHead.
  \tweak color #red c'\mf

  % This will \tweak the Accidental.
  \tweak Accidental.color #red dis'\mf

  % !! This will have no effect. !!
  \tweak DynamicText.color #red ees'\mf

  % This will \tweak the DynamicText.
  f' -\tweak color #red \mf
}
%%%%

Using post-event \tweak or using an equivalent \once \override (as shown below), you will then be able to see the second problem--the stencil provided is the wrong type. \markup is not a stencil, so you will need to convert it to one:

%%%%
\version "2.18.2"
{
  \once \override DynamicText.after-line-breaking = #(lambda (grob)
    (let* ((x-parent (ly:grob-parent grob X))
           (orig-sten (ly:grob-property x-parent 'stencil)))
      (ly:grob-set-property! x-parent 'stencil
        (grob-interpret-markup x-parent #{
           \markup \combine \stencil #orig-sten
             \with-dimensions #'(0 . 0) #'(0 . 0) \vcenter
             \with-color #red \draw-line #'(0 . 6) #}))))
  c'\mf
}
%%%%


-- Aaron Hill



reply via email to

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