lilypond-user
[Top][All Lists]
Advanced

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

Re: getting a markup command to generate a curve from a pair of points


From: Kevin Barry
Subject: Re: getting a markup command to generate a curve from a pair of points
Date: Sun, 15 Mar 2015 22:52:17 +0000

Hi Thomas,

Thank you the solution, and for explaining how. I learned a lot from this!

Kevin

On Sun, Mar 15, 2015 at 9:27 PM, Thomas Morley <address@hidden> wrote:


2015-03-15 22:07 GMT+01:00 Thomas Morley <address@hidden>:


2015-03-15 21:48 GMT+01:00 Kevin Barry <address@hidden>:
Hi LilyPond experts,

I'm trying to make a function that will draw a curved line given only a destination point (with some math I'll add later), but I've hit an early stumbling block: I can't seem to substitute variables for values in the path/curveto command list. The following code produces a `wrong-argument-type' error, but it points to scm/stencil.scm which isn't very helpful for figuring out what's wrong. Help appreciated!

\version "2.18.2"

#(define-markup-command (draw-curved-line layout props points)
   (number-pair?)
   (let ((xpt (car points))
         (ypt (cdr points)))
     (interpret-markup layout props
       (markup #:path 1 '((curveto 0 ypt 0 ypt xpt ypt))))))

\relative {
  b_\markup { \draw-curved-line #'(5 . 5) }
}


Hi Kevin,

in cases where i have no clue what's wrong and don't understand the error-message, I boil down the code and display all kind of data, values, ets

In your case I'd do:

#(define-markup-command (draw-curved-line layout props points)
   (number-pair?)
   (let ((xpt (car points))
         (ypt (cdr points)))
        
 (display '((curveto 0 ypt 0 ypt xpt ypt)))
 (newline)
 (display (caddar '((curveto 0 ypt 0 ypt xpt ypt))))
 (newline)
 (display (symbol? (caddar '((curveto 0 ypt 0 ypt xpt ypt)))))
        
        
     (interpret-markup layout props
       (markup
         ;#:path 1 '((curveto 0 ypt 0 ypt xpt ypt))
         "xy"
       ))
       ))



The problem should be clear now: the variables in '((curveto 0 ypt 0 ypt xpt ypt)) are not evaluated but taken as symbols.
You wrote a quoted list, but need some elements of the list be unquoted.
Shortest: use a combi of ` and ,


#(define-markup-command (draw-curved-line layout props points)
   (number-pair?)
   (let ((xpt (car points))
         (ypt (cdr points)))
     (interpret-markup layout props
       (markup
         #:path 1 `((curveto 0 ,ypt 0 ,ypt ,xpt ,ypt))

other syntax-possibilities:
(list (list 'curveto 0 ypt 0 ypt xpt ypt))
or most verbose:
(quasiquote
  ((curveto 0 (unquote ypt) 0 (unquote ypt) (unquote xpt) (unquote ypt))))

Look up 'quote', 'unquote', 'quasiquote' etc in the guile manual

       ))))



HTH,
 Harm




reply via email to

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