[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with custom noteheads

From: Jean Abou Samra
Subject: Re: Help with custom noteheads
Date: Thu, 11 Aug 2022 15:01:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

Le 11/08/2022 à 14:32, Valentin Petzel a écrit :
Hello Andrew,

is there any reason for using a custom circle approximation instead of simply
using (make-circle-stencil r th #f)?

The reason why your note heads are off is that a path stencil does not have an
extent. A path cotains arbitrary drawing commands, which means that Lilypond
does not really know how large the result would be. As such your Note Heads
are handled as points, but then draw outside of this, which means that
Lilypond cannot handle spacing properly.

What you need to do is to give the stencil an actual extent by using
ly:stencil-outline, as done here:

\version "2.23.11"

circa =
#(let* ((k 0.5522)
         (r 1)
         (th 0.1)
         (th2 (/ th 2))
         (rth (+ r th2)))
        (ly:make-stencil `(path ,th
                          (moveto ,r 0
                          curveto ,r ,k ,k ,r 0 ,r
                          curveto ,(- k) ,r ,(- r) ,k ,(- r) 0
                          curveto ,(- r) ,(- k) ,(- k) ,(- r) 0 ,(- r)
                          curveto ,k -1 1 ,(- k) 1 0
                          (cons 1 1) (cons 1 1))
        (make-filled-box-stencil (cons (- rth) rth) (cons (- rth) rth))))

You could also just replace the two (cons 1 1), which specify
the X and Y extents, with (cons (- rth) rth).

Better yet: use make-path-stencil, which computes the extents
automatically. (It used to do it wrongly in some cases, but I
fixed that in 2.23.11.)

Better yet: use make-circle-stencil, which draws a true circle
with the right extents, as you already said, and as demonstrated in
the message I sent at exactly the same time.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]