On Mon, May 4, 2015 at 3:56 AM, Menu Jacques <[email protected]> wrote:
> Hello folks,
>
> Someone recently supplied on this list a way to draw large, colored
> brackets to emphasize repeats, with fixed X offsets though.
>
> I tried to go one step further by defining functions in order to be able
> to specify the X offset at will.
>
> \displayMusic showed me what to put in their body, but I bump into the
> fact that the music itself is frozen is their code.
>
> How can I get the example below to work with a regular note as extra
> argument?
>
> I’d like to be able to write something such as:
>
> \myColoredLeftBracket d’2. #-4.6
>
> Or maybe would it be better and more in the LP spirit to be able to write:
>
> d’2. \myColoredLeftBracket #-4.6
>
> I don’t know how to get:
>
> 'duration
> (ly:make-duration 0)
> 'pitch
> (ly:make-pitch -1 0)
>
> at the right place from a music argument such as d’2. .
>
> The same question arises by the way for:
>
> (list 1 0.647058823529412 0)
>
> which is the orange color in this example.
>
> Thanks for you help!
>
> JM
>
>
> %%%%%%%%%%%%
>
> \version "2.19.17"
>
> coloredLeftRepeatBracketPath = #'(
> (moveto 1 -4.5)
> (lineto 0 -2.5)
> (lineto 0 2.5)
> (lineto 1 4.5))
>
> coloredRightRepeatBracketPath = #'(
> (moveto -1 -4.5)
> (lineto 0 -2.5)
> (lineto 0 2.5)
> (lineto -1 4.5))
>
> % Variables with frozen X offsets
>
> coloredLeftBracket =
> -\tweak layer #-1
> -\tweak extra-offset #'( -2.3 . -2.5)
> ^\markup {
> \with-color #(x11-color "orange")
> \with-dimensions #'(0 . 0) #'(0 . 0)
> \path #1 #coloredLeftRepeatBracketPath
> }
>
>
> coloredRightBracket =
> -\tweak layer #-1
> -\tweak extra-offset #'(4.4 . -3.1)
> ^\markup {
> \with-color #(x11-color "orange")
> \with-dimensions #'(0 . 0) #'(0 . 0)
> \path #1 #coloredRightRepeatBracketPath
> }
>
>
> % Attempts at parameterized functions instead of frozen X offsets
> % Code obtained thru \displayMusic and adapted
>
> myColoredLeftBracket =
> #(define-music-function (parser location x-offset) (number?)
> (make-music
> 'SequentialMusic
> 'elements
> (list (make-music
> 'NoteEvent
> 'articulations
> (list (make-music
> 'TextScriptEvent
> 'tweaks
> (list (cons (quote layer) -1)
> (cons (quote extra-offset) (cons x-offset -2.5)))
> 'direction
> 1
> 'text
> (markup
> #:line
> (#:with-color
> (list 1 0.647058823529412 0)
> (#:with-dimensions
> (cons 0 0)
> (cons 0 0)
> (#:path
> 1
> (list (list (quote moveto) 1 -4.5)
> (list (quote lineto) 0 -2.5)
> (list (quote lineto) 0 2.5)
> (list (quote lineto) 1 4.5))))))))
> 'duration
> (ly:make-duration 0)
> 'pitch
> (ly:make-pitch -1 0))))
> )
>
> myColoredRightBracket =
> #(define-music-function (parser location x-offset) (number?)
> (make-music
> 'SequentialMusic
> 'elements
> (list (make-music
> 'NoteEvent
> 'articulations
> (list (make-music
> 'TextScriptEvent
> 'tweaks
> (list (cons (quote layer) -1)
> (cons (quote extra-offset) (cons x-offset -3.1)))
> 'direction
> 1
> 'text
> (markup
> #:line
> (#:with-color
> (list 1 0.647058823529412 0)
> (#:with-dimensions
> (cons 0 0)
> (cons 0 0)
> (#:path
> 1
> (list (list (quote moveto) -1 -4.5)
> (list (quote lineto) 0 -2.5)
> (list (quote lineto) 0 2.5)
> (list (quote lineto) -1 4.5))))))))
> 'duration
> (ly:make-duration 0)
> 'pitch
> (ly:make-pitch -1 0))))
> )
>
>
> {
> \displayMusic {c1 \coloredLeftBracket}
> }
>
> {
> \displayMusic {d'2. \coloredRightBracket}
> }
>
> {
> \displayMusic {d'2.}
> }
>
> {
> \myColoredLeftBracket #-4.6
> }
>
> {
> \myColoredRightBracket #6.0
> }
>
> %%%%%%%%%%%%
>
I'm not going to be able to give a detailed explanation right now (am going
to be late!), but the following shows how you might get
\myColoredLeftBracket to work with color and _music_ arguments.
Note that you could roll both commands into a command which would
parenthesize a range of music.
HTH,
David
%%%%%%%%%%%%%%%%%%
\version "2.19.17"
myColoredLeftBracket =
#(define-music-function (parser location x-offset color music)
(number? color? ly:music?)
(let ((elts (ly:music-property music 'elements)))
(if (pair? elts)
(let ((art (ly:music-property (car elts) 'articulations)))
(set! (ly:music-property (car elts) 'articulations)
(cons (make-music
'TextScriptEvent
'tweaks
(list (cons (quote layer) -1)
(cons (quote extra-offset) (cons x-offset -2.5)))
'direction
1
'text
(markup
#:line
(#:with-color
color
(#:with-dimensions
(cons 0 0)
(cons 0 0)
(#:path
1
(list (list (quote moveto) 1 -4.5)
(list (quote lineto) 0 -2.5)
(list (quote lineto) 0 2.5)
(list (quote lineto) 1 4.5)))))))
art)))))
music)
{
\myColoredLeftBracket #-4.6 #(list 1 0.647058823529412 0) { d'->-\fermata
}
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user