[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: Coordinates of the noteheads a tie/slur is attached to
From:       Urs Liska <ul () openlilylib ! org>
Date:       2017-01-25 8:48:07
Message-ID: 1dc64264-8c4b-bbab-3be6-1fe4738a165a () openlilylib ! org
[Download RAW message or body]

Hi David,

thanks for your code


Am 24.01.2017 um 15:42 schrieb David Nalesnik:
> Hi Urs,
>
> On Tue, Jan 24, 2017 at 7:19 AM, Urs Liska <ul@openlilylib.org> wrote:
>> Hi,
>>
>> how can I find the coordinates of the two note heads a tie or slur is
>> attached to?
>>
>> ...
> Try:
>
> ...
>
> You can get the Y position by 'staff-position of the notes and
> calculate the Y from the staff-space, staff-width, etc.
>
> HTH,

Indeed. I think for the next step I have everything I need, I can
determine the horizontal distance of the note heads and the Y position,
and from there I'll be able to create a path. The following isn't the
path I'm after but it shows how (and that) it works.
What I'll have to deal with now is the direction and the proper handling
of chords (of course it's not a solution to simply pick the first
notehead). And of course I'll clean up the bindings.

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

\version "2.19.54"

#(define (get-noteheads grob)
   (if (grob::has-interface grob 'note-column-interface)
       (ly:grob-array->list (ly:grob-object grob 'note-heads))
       (list grob)))

#(define (my-notehead-positions grob)
   (let* ((sys (ly:grob-system grob))
          (lb (ly:spanner-bound grob LEFT))
          (lb-noteheads (get-noteheads lb))
          (lb-x (ly:grob-relative-coordinate (first lb-noteheads) sys X))
          (lb-y (ly:grob-property (first lb-noteheads) 'staff-position))
          (lb-y-start (- (/ lb-y 2) 1.5))
          (rb (ly:spanner-bound grob RIGHT))
          (rb-noteheads (get-noteheads rb))
          (rb-x (ly:grob-relative-coordinate (first rb-noteheads) sys X))
          (rb-y (ly:grob-property (first rb-noteheads) 'staff-position))
          (rb-y-end (- (/ rb-y 2) 1.5))
          (grob-width (- rb-x lb-x))
          )
     (ly:make-stencil
      `(path
        0.5
        `(moveto 0 ,,lb-y-start
           lineto ,,grob-width ,,rb-y-end)))
     ))

\relative c' {
  \override Slur.stencil = #my-notehead-positions
  \override Tie.stencil = #my-notehead-positions
  c~ c <g' c>2( e)
}

\new PianoStaff <<
  \new Staff \relative c' {
    \override Slur.stencil = #my-notehead-positions
    \override Tie.stencil = #my-notehead-positions
    c~ c c( e)
  }
  \new Staff {
    R1*2
  }
>>

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


>
> David

-- 
ul@openlilylib.org
https://openlilylib.org
http://lilypondblog.org


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic