2015-03-15 21:48 GMT+01:00 Kevin Barry <barr...@gmail.com>:

> 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))
       ))))



HTH,
 Harm
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to