]> git.donarmstrong.com Git - lilypond.git/commitdiff
Support configurable join and cap styles for 'path.
authorPatrick McCarty <pnorcks@gmail.com>
Sat, 19 Jun 2010 03:16:06 +0000 (20:16 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Fri, 13 Aug 2010 22:03:08 +0000 (15:03 -0700)
scm/output-ps.scm
scm/output-svg.scm

index 128b1d410424ea26db70b68255b4f2d285638deb..54ba874d00d5e7efc24b827a557ffc07ff29d404 100644 (file)
@@ -29,6 +29,7 @@
 
 (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" ""))))
index 3a82c6f81507750df8fe9a639919acf19bcd2062..40aafb420f18d0348eada77f15a0a2b8e10781b0 100644 (file)
@@ -29,6 +29,7 @@
   (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)