[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reading a property
From: |
Klaus Blum |
Subject: |
Re: Reading a property |
Date: |
Wed, 1 Apr 2015 13:57:55 -0700 (MST) |
Hi David,
thanks for coming onboard.
First of all, I've got a function that returns a stencil:
#(define (makeDeltaSpan y-l-lower y-l-upper y-r-lower y-r-upper frame-color
fill-color stepLeft stepRight open-on-bottom open-on-top
thick pad X-ext-param open-on-left open-on-right radius
)
...etc... all the stuff needed for drawing
)
Then, this stencil replaces the default stencil of HorizontalBracket:
genericSpan =
#(define-music-function (parser location y-l-lower y-l-upper y-r-lower
y-r-upper frame-color fill-color stepLeft stepRight open-on-bottom
open-on-top)
(number? number? number? number? scheme? scheme? number? number? boolean?
boolean?)
#{
\once\override HorizontalBracket.stencil =
$(lambda (grob)
(let* (
(area (ly:horizontal-bracket::print grob))
(thick (ly:grob-property grob 'line-thickness 1))
(pad (ly:grob-property grob 'broken-bound-padding 0))
(radius (ly:grob-property grob 'hair-thickness 0))
(X-ext-param (ly:stencil-extent area X))
(open-on-left (= 1 (ly:item-break-dir (ly:spanner-bound
grob LEFT ))))
(open-on-right (= -1 (ly:item-break-dir (ly:spanner-bound
grob RIGHT))))
)
(makeDeltaSpan y-l-lower y-l-upper y-r-lower y-r-upper
frame-color fill-color stepLeft stepRight open-on-bottom open-on-top
thick pad X-ext-param open-on-left open-on-right radius)
))
\once\override HorizontalBracket.Y-offset = #0
#})
Although it reads out some properties, this function still has a lot of
parameters. So, I'd like to build some specialized versions.
So I could define:
\override HorizontalBracket.zigzag-width = #2
And build a new function:
ZZSpan =
#(define-music-function (parser location y-lower y-upper frame-color
fill-color)
(number? number? scheme? scheme?)
#{
\genericSpan $y-lower $y-upper $y-lower $y-upper $frame-color
$fill-color
#2 #2 % Here I would like to read out the value from
HorizontalBracket.zigzag-width
##f ##f
#})
If other functions could call \genericSpan, it would be a more elegant way.
But maybe it's easier just to copy-paste the code, as reading out properties
seems to get even more complicated.
Cheers,
Klaus
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/Reading-a-property-tp173954p173969.html
Sent from the User mailing list archive at Nabble.com.