lilypond-user
[Top][All Lists]
Advanced

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

Re: How to restore default-stem-attachment with note-head-stencil-overri


From: Thomas Morley
Subject: Re: How to restore default-stem-attachment with note-head-stencil-override?
Date: Wed, 18 Jul 2012 22:56:09 +0200

2012/7/18 Keith OHara <address@hidden>:
> Thomas Morley <thomasmorley65 <at> googlemail.com> writes:
>
>> adding sth to a NoteHead-stencil via stencil-override returns a weird
>> output with stemmed NoteHeads.
>>
>> In the code below I added a box around the default-note-head and the
>> stem is moving away.
>
> stem-attachment is expressed as a fraction of the size of the note-head.
> That would have been convenient if your NoteHead-stencil were a new
> note-head, but in your case with the box you will need to tell LilyPond
> what portion of the stencil is actually the notehead.  Probably the ratio
> of your note-head width to the width of your box.

Hi Keith,

thanks for your reply!
I tried to follow your explication while investigating an untweaked NoteHead.
But reading out x- and y-length of the NoteHead-stencil, and comparing
their quotient with the quotient build from the values I got via
'stem-attachment, different results are returned.

\version "2.15.42"

\relative c' {
        \override Stem #'color = #red
        \override Stem #'layer = #-10
        c4
        \override NoteHead #'stencil =
         #(lambda (grob)
          (let* ((stil (ly:note-head::print grob))
                 (x-length (interval-length (ly:stencil-extent stil X)))
                 (y-length (interval-length (ly:stencil-extent stil Y)))
                 (st-pos (ly:grob-property grob 'stem-attachment))
                 (r1 (/ (car st-pos) (cdr st-pos)))
                 (r2 (/ x-length y-length ))
          )
          (newline)(display "x-length ")(display x-length)
          (newline)(display "y-length ")(display y-length)
          (newline)(display "st-pos   ")(display st-pos)
          (newline)(display "(/ (car st-pos) (cdr st-pos))       ")(display r1)
          (newline)(display "(/ x-length y-length )              ")(display r2)

          (ly:grob-set-property! grob 'stem-attachment (cons x-length y-length))
          stil))

        c4
}

log-excerpt:

GNU LilyPond 2.15.42
Processing `stem-attach-01.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
x-length 1.316178
y-length 1.100012
st-pos   (1.0 . 0.341476274804275)
(/ (car st-pos) (cdr st-pos))       2.92846113708243
(/ x-length y-length )              1.19651240168289
Finding the ideal number of pages...

What am I missing?

-Harm



reply via email to

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