Distance of grob to barlines

2015-08-21 Thread Andrew Bernard
Can anybody kindly point me to code examples showing how to find the distance 
of a grob to its nearest enclosing barlines, in Scheme?

>From what I can gather, it’s not a simple function call, but involves some 
>processing of column arrays, which I can’t find documentation on.

Andrew



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Distance of grob to barlines

2015-08-22 Thread David Nalesnik
Hi Andrew,

On Fri, Aug 21, 2015 at 6:51 PM, Andrew Bernard 
wrote:

> Can anybody kindly point me to code examples showing how to find the
> distance of a grob to its nearest enclosing barlines, in Scheme?
>

I don't know of any examples out there, be this will do it.

This uses the horizontal coordinate of the grob and barline as a simple
demonstration.  Depending on what precisely you mean by "distance" (right
edge to left edge, left edge to right edge, etc.) you may want to use
ly:grob-extent.

HTH,
David

%%
 \version "2.19.23"

#(define (distance-to-nearest-barline dir)
   (lambda (grob)
 (let* ((refp (ly:grob-system grob))
(all-elts (ly:grob-array->list (ly:grob-object refp
'all-elements)))
(barlines (filter (lambda (elt)
(grob::has-interface elt
'bar-line-interface))
  all-elts))
(me-pos (grob::rhythmic-location grob))
(pred? (if (= LEFT dir) rhythmic-location>=?
rhythmic-location___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Distance of grob to barlines

2015-08-22 Thread David Nalesnik
On Sat, Aug 22, 2015 at 11:55 AM, David Nalesnik 
wrote:

> Hi Andrew,
>
> On Fri, Aug 21, 2015 at 6:51 PM, Andrew Bernard 
> wrote:
>
>> Can anybody kindly point me to code examples showing how to find the
>> distance of a grob to its nearest enclosing barlines, in Scheme?
>>
>
> I don't know of any examples out there, be this will do it.
>
> This uses the horizontal coordinate of the grob and barline as a simple
> demonstration.  Depending on what precisely you mean by "distance" (right
> edge to left edge, left edge to right edge, etc.) you may want to use
> ly:grob-extent.
>

That is, instead of ly:grob-relative-coordinate.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user