If you want to create a custom shape or symbol, you can use the make-connected-path-stencil
scheme function. This function takes the following six arguments, and returns a stencil
.
1. A list of lists defining the coordinates of the path. The path automatically starts at the origin point of (0 0). To draw a straight line to the next point, simply indicate the X and Y coordinates of the next point like this: (1 -3)
To draw a cubic Bézier curve to the next point, enter a list of six numbers like this: (-6 -2 -6 7 0 5)
The first two numbers are the X and Y coordinates of the first control point. The middle two are the X and Y coordinates of the second control point. The last two are the X and Y coordinates of the destination point.
2. A number indicating the thickness of the line.
3. A number that scales the stencil on the X-axis.
4. A number that scales the stencil on the Y-axis.
5. A boolean (#t / #f) indicating whether the path automatically connects back to the origin point (0 0).
6. A boolean (#t / #f) indicating whether the shape created by the path is to be filled.
This snippet demonstrates using stencils
as an override for other stencils
, and also how they can be used in \markup
. The snippet also shows how to use ly:stencil-translate
to shift the position of the stencil. This is sometimes needed since the origin point of the path is "hard-coded" to always be (0 0).
Using make-connected-path-stencil
has several advantages compared with using ly:make-stencil
and path
(as shown here: http://lsr.di.unimi.it/LSR/Item?id=623). One is that you do not have to manually specify the width and height of the stencil, since it gets calculated automatically.