[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Postscript trick
From: |
Nicolas Sceaux |
Subject: |
Re: Postscript trick |
Date: |
Sat, 15 May 2004 16:40:07 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Sat, 15 May 2004 15:51:03 +0200, Jan a dit :
> Scott Webber writes:
>> I'm trying to use lisp or schema or whatever to add postscript to a note,
>> but I don't really understand the syntax exactly.
> Try something like:
> { c c c c-"\\embeddedps{1 1 moveto 2 2 rlineto stroke}" }
> I'm assuming you use 2.3 CVS, because otherwise you won't be able to
> use ly snippets inside scheme. However
> % can't get this to work
> #(define (slash x)
> ;; #{ \notes { $x-"\\embeddedps{1 1 moveto 2 2 rlineto stroke}" } #}
> #{ \notes { $x -"\\embeddedps{1 1 moveto 2 2 rlineto stroke}" } #}
> )
This does not work because the $x is not replaced by the printed value
of x. Instead, a tmpvariable is introduced, that is bound to the value
of x (ie, 'c), and "\tmpvariable" is then written in the pattern instead of
$x. So you have (define tmpvar x) somewhere and then
\tmpvar -"\\embeddedps{1 1 moveto 2 2 rlineto stroke}"
is parsed.
> % { c c c c #(slash 'c) }
Using def-markup-command or ly:make-music-function :
#(def-markup-command (slash paper props) ()
(interpret-markup paper props "\\embeddedps{1 1 moveto 2 2 rlineto stroke}"))
slash = #(ly:make-music-function (list ly:music?)
(lambda (location note)
(set! (ly:music-property note 'elements)
(cons (make-music 'TextScriptEvent
'text (markup "\\embeddedps{1 1 moveto 2 2 rlineto
stroke}"))
(ly:music-property note 'elements)))
note))
\score {
\notes {
c'-"\\embeddedps{1 1 moveto 2 2 rlineto stroke}"
c'-\markup \slash
\slash c'
}
}
nicolas