From: Patrick McCarty Date: Sat, 19 Jun 2010 03:16:06 +0000 (-0700) Subject: Support configurable join and cap styles for 'path. X-Git-Tag: release/2.13.31-1~80 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cf5a32da8dea60a586fb14f7a5ae37417f01c178;p=lilypond.git Support configurable join and cap styles for 'path. --- diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 128b1d4104..54ba874d00 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -29,6 +29,7 @@ (use-modules (guile) (ice-9 regex) + (ice-9 optargs) (srfi srfi-1) (srfi srfi-13) (scm framework-ps) @@ -284,7 +285,7 @@ (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* @@ -307,8 +308,14 @@ (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" "")))) diff --git a/scm/output-svg.scm b/scm/output-svg.scm index 3a82c6f815..40aafb420f 100644 --- a/scm/output-svg.scm +++ b/scm/output-svg.scm @@ -29,6 +29,7 @@ (guile) (ice-9 regex) (ice-9 format) + (ice-9 optargs) (lily) (srfi srfi-1) (srfi srfi-13)) @@ -548,7 +549,7 @@ 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* @@ -576,10 +577,10 @@ (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)