lilypond-user
[Top][All Lists]
Advanced

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

Re: variable variables


From: Paul Morris
Subject: Re: variable variables
Date: Thu, 11 Dec 2014 18:26:16 -0700 (MST)

Gerjan Piksen wrote
> I would be very very very happy with some help on this : )

Let me see if I can help.  I think the first step is to use something
besides embedded-ps.  make-connected-path-stencil will be easier to work
with.  The following will let you set the width like you want.

%%%%%%%%%%%%%%%
\version "2.18.2"

qRecta =
#(lambda (x)
   (make-connected-path-stencil
    `((0 0.55)
      (,x 0.55)
      (,x -0.55)
      (0 -0.55)
      (0 0))
    0 ;; line thickness
    1 ;; X-axis scaling factor
    1 ;; Y-axis scaling factor
    #t ;; auto-connect path to origin point? (0 0)
    #t)) % filled path?

X =
#(define-music-function (parser location w) (number?)
   #{
     \override NoteHead #'X-offset = #0
     \override NoteHead #'stencil = #(qRecta w)
   #})

\new Staff
{
  \absolute
  \X #0.3 <e' f' g' a' b' c'>8
  \X #0.5 <e' f' g' a' b' c'>8
}


%%%%%%%%%%%%%%
% another option, make-path-stencil
% available in latest 2.19 but not 2.18.2
qRecta-B =
#(lambda (x)
   (make-path-stencil
    `(moveto 0 0.55
       lineto ,x 0.55
       lineto ,x -0.55
       lineto 0 -0.55
       closepath)
    0 ;; line thickness
    1 ;; X-axis scaling factor
    1 ;; Y-axis scaling factor
    #t)) % filled path?

%%%%%%%%%%%%%%%

However, the output is not exactly what we get from what's below, which I
assume is what you want.  So there's still more to be done...

HTH,
-Paul


%%%%%%%%%%%%%%%
\version "2.18.2"

qRecta =
#(ly:make-stencil
  (list 'embedded-ps
    "gsave
    currentpoint translate
    newpath
    0 0.55 moveto
    0.33375 0.55 lineto
    0.33375 -0.55 lineto
    0 -0.55 lineto
    closepath
    fill
    grestore")
  (cons 0.5 1.3125)
  (cons 0 0))

\new Staff {
  \absolute
  \override NoteHead #'X-offset = #0
  \override NoteHead #'stencil = \qRecta
  <e' f' g' a' b' c'>8
  <e' f' g' a' b' c'>8
}






--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/variable-variables-tp169395p169397.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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