lilypond-user
[Top][All Lists]
Advanced

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

Re: Help with custom noteheads


From: Valentin Petzel
Subject: Re: Help with custom noteheads
Date: Thu, 11 Aug 2022 14:32:19 +0200

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:stencil-outline
       (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))))


circ =
#(make-circle-stencil 1 0.1 #f)

insta = {
   c'4 d' e' f' g' a' b' c''
}

\score {
   \new Staff \insta

   \layout {
     \context {
       \Score
       % custom circular noteheads
       \override NoteHead.stencil = #circa
     }
   }
}

\score {
   \new Staff \insta

   \layout {
     \context {
       \Score
       % builtin circular noteheads
       \override NoteHead.stencil = #circ
     }
   }
}

Cheers,
Valentin

Am Donnerstag, 11. August 2022, 13:40:06 CEST schrieb Andrew Bernard:
> So here is an MWE showing the start of what I want to do - make circular
> unfilled noteheads, and fitting in the staff size. This is only a start,
> as the set of note styles I need have many extra doodads, so this is
> just to get going.
> 
> It's been a long time since I have done any Lilypond Scheme. I'm wanting
> help on how to size and position the noteheads properly. This initial
> code is only my first sketch. I'm aware I need to flip the side when the
> stem points down - that's not the main focus. I am also foggy on the
> last arguments specfying the x and y extents. I can't recall what
> extents are and how they affect this context (having trouble searching
> for extent in the NR).
> 
> The code is my own using the Bezier approximation for a circle. The
> variable k is kappa - as referenced in a previous post on 'Circles' and
> r is radius.
> 
> ====
> 
> \version "2.23.11"
> 
> circa =
> #(let ((k 0.5522)
>        (r 1))
>        (ly:make-stencil `(path 0.1
>      (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)))
> 
> insta = {
>    c'4 d' e' f' g' a' b' c''
> }
> 
> \score {
>    \new Staff \insta
> 
>    \layout {
>      \context {
>        \Score
>        % custom circular noteheads
>        \override NoteHead.stencil = #circa
>      }
>    }
> }
> 
> ====
> 
> 
> Andrew

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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