lilypond-user
[Top][All Lists]
Advanced

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

Re: get-staff-size? get-note-head-width?


From: Mark Polesky
Subject: Re: get-staff-size? get-note-head-width?
Date: Sun, 11 Jan 2009 22:19:50 -0800 (PST)

Mark Polesky wrote:

> Is there a way to detect the current staff-size
> within a music-function? Is there a way to 
> detect the width of a note-head within a music-
> function?

I don't know about staff-size, but you can get
the width of a note-head with a callback 
proceduresimilar to the one described here:
  http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Difficult-tweaks

Note that the default notehead stencil is
ly:note-head::print
   http://lilypond.org/doc/v2.12/Documentation/user/lilypond-internals/NoteHead

Also see the ly:stencil-extent procedure:
   
http://lilypond.org/doc/v2.12/Documentation/user/lilypond-internals/Scheme-functions#index-ly_003astencil_002dextent

Essentially, you want something like a 
ly:note-head::calc-width callback procedure.
With ly:stencil-extent and ly:note-head::print,
you can create your own...

_______________________________________________


\version "2.12.1"

#(define (ly:note-head::calc-width grob)
  (let* ((X-extent (ly:stencil-extent (ly:note-head::print grob) 0))
         (width (- (cdr X-extent) (car X-extent))))
    width))

oneWidthRight = \override NoteHead #'X-offset = #ly:note-head::calc-width
music = { d'4 g,8 a b c d4 g, g }
\relative { \time 3/4 \music }
\relative { \time 3/4 \oneWidthRight \music }

_______________________________________________


Hope this helps.
- Mark



      

Attachment: calc-width.png
Description: PNG image


reply via email to

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