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: Sat, 21 Jul 2012 09:36:37 +0200

2012/7/21 Thomas Morley <address@hidden>:
> 2012/7/21 Keith OHara <address@hidden>:
>> On Fri, 20 Jul 2012 15:25:53 -0700, Thomas Morley
>> <address@hidden> wrote:
>>
>>>
>>> thanks for all your hints.
>>> I'm coming up now with the code below.
>>>
>>
>> I see, car and cdr extract pointers to the nodes of a tuple.  So to me it
>> looks like your data flow was not quite right.  You want the new
>> stem-attachment to be proportional to the old, so multiply by the elements
>> of the old stem-attachment, x with x, and y with y.
>>
>>
>> restoreStemAttachment =
>> \override NoteHead #'stencil =
>>   #(lambda (grob)
>>     (let* ((stencil (ly:note-head::print grob))
>>            (new-stil (grob-interpret-markup grob (markup #:box #:stencil
>> stencil)))
>>            (stem-attach (ly:grob-property grob 'stem-attachment))
>>
>>            (x-length-stil (interval-length (ly:stencil-extent stencil X)))
>>            (x-length-new-stil (interval-length (ly:stencil-extent new-stil
>> X)))
>>            (x-coord (* (car stem-attach) (/ x-length-stil
>> x-length-new-stil)))
>>
>>
>>            (y-length-stil (interval-length (ly:stencil-extent stencil Y)))
>>            (y-length-new-stil (interval-length (ly:stencil-extent new-stil
>> Y)))
>>            (y-coord (* (cdr stem-attach) (/ y-length-stil
>> y-length-new-stil))))
>>
>>
>>   (ly:grob-set-property! grob 'stem-attachment (cons x-coord y-coord))
>> new-stil))
>>
>
> Works like a charm.
>
> Thanks a lot,
>   Harm

Same mail again. Forgot to answer all,



reply via email to

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