Embedding native PostScript in a \markup block: Difference between revisions
Appearance
m New category |
Improve example to actually show three PostScript curves, also avoiding cropping in PDF output |
||
| Line 1: | Line 1: | ||
PostScript code can be directly inserted inside a <code>\markup</code> block. | PostScript code can be directly inserted inside a <code>\markup</code> block. | ||
For technical reasons, this doesn't show up in the Wiki because <code>\postscript</code> only works with LilyPond's PS backend and is neither supported in the SVG (used in this Wiki) or the Cairo backend. | |||
In general it is recommended to use LilyPond's native graphical markup commands like <code>\polygon</code> instead, which can be used with all LilyPond backends. | |||
<lilypond version="2.24"> | <lilypond version="2.24"> | ||
\relative c'' { | \relative c'' { | ||
a2-\markup \postscript "0 3 moveto | |||
5 2 rlineto | |||
stroke" | |||
-\markup \postscript "[1 1] 0 setdash | |||
0 0 moveto | |||
5 2 rlineto | |||
stroke" | |||
b2-\markup \postscript "1 1 moveto | |||
0 0 1 2 8 4 10 2 rcurveto | |||
stroke" | |||
a'1 | a'1 | ||
} | } | ||
</lilypond> | </lilypond> | ||
[[Category:Editorial annotations]] | [[Category:Editorial annotations]] | ||
[[Category:Specific notation]] | |||
[[Category:Text]] | [[Category:Text]] | ||
[[Category:Included in the official documentation]] | [[Category:Included in the official documentation]] | ||
[[Category:Snippet]] | [[Category:Snippet]] | ||
Revision as of 09:30, 12 December 2025
PostScript code can be directly inserted inside a \markup block.
For technical reasons, this doesn't show up in the Wiki because \postscript only works with LilyPond's PS backend and is neither supported in the SVG (used in this Wiki) or the Cairo backend.
In general it is recommended to use LilyPond's native graphical markup commands like \polygon instead, which can be used with all LilyPond backends.
\version "2.24"
\relative c'' {
a2-\markup \postscript "0 3 moveto
5 2 rlineto
stroke"
-\markup \postscript "[1 1] 0 setdash
0 0 moveto
5 2 rlineto
stroke"
b2-\markup \postscript "1 1 moveto
0 0 1 2 8 4 10 2 rcurveto
stroke"
a'1
}