(use-modules (guile)
(ice-9 regex)
+ (ice-9 optargs)
(srfi srfi-1)
(srfi srfi-13)
(scm framework-ps)
(cdr y)
url))
-(define (path thickness exps)
+(define* (path thickness exps #:optional (cap 'round) (join 'round) (fill? #f))
(define (convert-path-exps exps)
(if (pair? exps)
(let*
(convert-path-exps (drop rest arity))))
'()))
-
- (ly:format
- "gsave currentpoint translate 1 setlinecap ~a setlinewidth\n~l stroke grestore"
- thickness
- (convert-path-exps exps)))
+ (let ((cap-numeric (case cap ((butt) 0) ((round) 1) ((square) 2)))
+ (join-numeric (case join ((miter) 0) ((round) 1) ((bevel) 2))))
+ (ly:format
+ "gsave currentpoint translate
+~a setlinecap ~a setlinejoin ~a setlinewidth
+~l gsave stroke grestore ~a grestore"
+ cap-numeric
+ join-numeric
+ thickness
+ (convert-path-exps exps)
+ (if fill? "fill" ""))))
(guile)
(ice-9 regex)
(ice-9 format)
+ (ice-9 optargs)
(lily)
(srfi srfi-1)
(srfi srfi-13))
x-max y-min
x-max 0)))))
-(define (path thick commands)
+(define* (path thick commands #:optional (cap 'round) (join 'round) (fill? #f))
(define (convert-path-exps exps)
(if (pair? exps)
(let*
(entity 'path ""
`(stroke-width . ,thick)
- '(stroke-linejoin . "round")
- '(stroke-linecap . "round")
+ `(stroke-linejoin . ,(symbol->string join))
+ `(stroke-linecap . ,(symbol->string cap))
'(stroke . "currentColor")
- '(fill . "none")
+ `(fill . ,(if fill? "currentColor" "none"))
`(d . ,(apply string-append (convert-path-exps commands)))))
(define (placebox x y expr)