Hi Klaus,
On Sat, Jan 17, 2015 at 9:54 AM, Klaus Blum <benbigno...@gmx.de> wrote:
> Hi David,
>
> one more big THANK YOU for your fast reply.
>
You're very welcome!
> Yes, it was very helpful.
> I have updated music-boxer-stencil so that it works again with the
> boxEngraver. Finally I did some cleanup to my messy code in make-box.d).
>
>
Looks great! I like how you fixed the boundaries of the fill---looks much
better.
I've streamlined two of the variable definitions in music-boxer-stencil. I
think you will also find it very helpful if you use line breaks and
indentation to clarify the structure of if-expressions and such. As I was
looking at this, I went ahead and changed the formatting to help me follow
the code. See attached excerpt.
Hope this helps!
David
#(define (make-box thick padding filled fill-color open-on-left open-on-right xext yext)
(let* ((xext (interval-widen xext padding))
(yext (interval-widen yext padding)))
(ly:stencil-add
(if filled
(ly:make-stencil (list 'color fill-color
(list 'round-filled-box
(- (- (car xext) thick)) (+ (cdr xext) thick)
(- (car yext)) (cdr yext)
0.0)
xext yext))
empty-stencil)
(if (> thick 0)
(make-filled-box-stencil
(cons (- (car xext) thick) (+ (cdr xext) thick))
(cons (- (car yext) thick) (car yext)))
empty-stencil)
(if (> thick 0)
(make-filled-box-stencil
(cons (- (car xext) thick) (+ (cdr xext) thick))
(cons (cdr yext) (+ (cdr yext) thick)))
empty-stencil)
(if (and (not open-on-right) (> thick 0))
(make-filled-box-stencil
(cons (cdr xext) (+ (cdr xext) thick))
yext)
empty-stencil)
(if (and (not open-on-left) (> thick 0))
(make-filled-box-stencil
(cons (- (car xext) thick) (car xext))
yext)
empty-stencil)
)))
#(define (music-boxer-stencil grob)
(let* ((elts (ly:grob-object grob 'elements))
(refp-X (ly:grob-common-refpoint-of-array grob elts X))
(X-ext (ly:relative-group-extent elts refp-X X))
(refp-Y (ly:grob-common-refpoint-of-array grob elts Y))
(Y-ext (ly:relative-group-extent elts refp-Y Y))
(padding (ly:grob-property grob 'padding 0.3))
(thick (ly:grob-property grob 'thickness 0.1))
(filled (ly:grob-property grob 'filled #f))
(fill-color (ly:grob-property grob 'fill-color grey))
(offset (ly:grob-relative-coordinate grob refp-X X))
; (left-bound (ly:spanner-bound grob LEFT))
; (right-bound (ly:spanner-bound grob RIGHT))
; (break-dir-L (ly:item-break-dir left-bound))
; (break-dir-R (ly:item-break-dir right-bound))
; (open-on-left (if (= 1 break-dir-L) #t #f))
; (open-on-right (if (= -1 break-dir-R) #t #f))
(open-on-left
(and (ly:spanner? grob)
(= 1 (ly:item-break-dir (ly:spanner-bound grob LEFT)))))
; (open-on-left
; (if (ly:spanner? grob)
; (if (= 1 (ly:item-break-dir (ly:spanner-bound grob LEFT)))
; #t #f)
; #f))
(open-on-right
(and (ly:spanner? grob)
(= -1 (ly:item-break-dir (ly:spanner-bound grob RIGHT)))))
;(open-on-right
;(if (ly:spanner? grob)
; (if (= -1 (ly:item-break-dir (ly:spanner-bound grob RIGHT)))
; #t #f)
; #f))
(stil (make-box thick padding filled fill-color
open-on-left open-on-right X-ext Y-ext))
)
(ly:stencil-translate-axis stil (- offset) X)
)
)
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user