]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/output-svg.scm
Imported Upstream version 2.16.0
[lilypond.git] / scm / output-svg.scm
index 3132175414123ef86d6f360eccbe8f6296cc99f5..9f10629eacf7a6f2a3f4fc913aaa5ff3ee9a65a3 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; Copyright (C) 2002--2011 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; Copyright (C) 2002--2012 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;;                Patrick McCarty <pnorcks@gmail.com>
 ;;;;
 ;;;; LilyPond is free software: you can redistribute it and/or modify
                      (value (cdr x)))
                  (if (number? value)
                      (set! value (ly:format "~4f" value)))
-                 (format " ~s=\"~a\"" attr value)))
+                 (format #f " ~s=\"~a\"" attr value)))
              attributes-alist)))
 
 (define-public (eo entity . attributes-alist)
   "o = open"
-  (format "<~S~a>\n" entity (attributes attributes-alist)))
+  (format #f "<~S~a>\n" entity (attributes attributes-alist)))
 
 (define-public (eoc entity . attributes-alist)
   "oc = open/close"
-  (format "<~S~a/>\n" entity (attributes attributes-alist)))
+  (format #f "<~S~a/>\n" entity (attributes attributes-alist)))
 
 (define-public (ec entity)
   "c = close"
-  (format "</~S>\n" entity))
+  (format #f "</~S>\n" entity))
+
+(define (start-enclosing-id-node s)
+  (string-append "<g id=\"" s "\">\n"))
+
+(define (end-enclosing-id-node)
+  "</g>\n")
 
 (define-public (comment s)
   (string-append "<!-- " s " -->\n"))
@@ -86,7 +92,7 @@
   (define (helper lst)
     (if (null? lst)
        '()
-       (cons (format "~S ~S" (car lst) (- (cadr lst)))
+       (cons (format #f "~S ~S" (car lst) (- (cadr lst)))
              (helper (cddr lst)))))
 
   (string-join (helper lst) " "))
 ;;; stencil outputters
 ;;;
 
-(define (bezier-sandwich lst thick)
-  (let* ((first (list-tail lst 4))
-        (second (list-head lst 4)))
-    (entity 'path ""
-           '(stroke-linejoin . "round")
-           '(stroke-linecap . "round")
-           '(stroke . "currentColor")
-           '(fill . "currentColor")
-           `(stroke-width . ,thick)
-           `(d . ,(string-append (svg-bezier first #f)
-                                 (svg-bezier second #t))))))
-
 (define (char font i)
   (dispatch
    `(fontify ,font ,(entity 'tspan (char->entity (integer->char i))))))
 
 (define (dashed-line thick on off dx dy phase)
   (draw-line thick 0 0 dx dy
-            `(stroke-dasharray . ,(format "~a,~a" on off))))
+            `(stroke-dasharray . ,(format #f "~a,~a" on off))))
 
 (define (draw-line thick x1 y1 x2 y2 . alist)
   (apply entity 'line ""
 (define (no-origin)
   "")
 
-(define (oval x-radius y-radius thick is-filled)
-  (let ((x-max x-radius)
-       (x-min (- x-radius))
-       (y-max y-radius)
-       (y-min (- y-radius)))
-    (entity
-      'path ""
-      '(stroke-linejoin . "round")
-      '(stroke-linecap . "round")
-      `(fill . ,(if is-filled "currentColor" "none"))
-      `(stroke . "currentColor")
-      `(stroke-width . ,thick)
-      `(d . ,(ly:format "M~4f ~4fC~4f ~4f ~4f ~4f ~4f ~4fS~4f ~4f ~4f ~4fz"
-                       x-max 0
-                       x-max y-max
-                       x-min y-max
-                       x-min 0
-                       x-max y-min
-                       x-max 0)))))
-
 (define* (path thick commands #:optional (cap 'round) (join 'round) (fill? #f))
   (define (convert-path-exps exps)
     (if (pair? exps)
                                  (closepath . z))
                                "")))
 
-         (cons (format "~a~a" svg-head (number-list->point args))
+         (cons (format #f "~a~a" svg-head (number-list->point args))
                (convert-path-exps (drop rest arity))))
        '()))
 
     `(points . ,(string-join
                  (map offset->point (ly:list->offsets '() coords))))))
 
-(define (repeat-slash width slope thickness)
-  (define (euclidean-length x y)
-    (sqrt (+ (* x x) (* y y))))
-  (let* ((x-width (euclidean-length thickness (/ thickness slope)))
-        (height (* width slope)))
-    (entity
-      'path ""
-      '(fill . "currentColor")
-      `(d . ,(ly:format "M0 0l~4f 0 ~4f ~4f ~4f 0z"
-                       x-width width (- height) (- x-width))))))
-
 (define (resetcolor)
   "</g>\n")
 
     '(fill . "currentColor")))
 
 (define (setcolor r g b)
-  (format "<g color=\"rgb(~a%, ~a%, ~a%)\">\n"
+  (format #f "<g color=\"rgb(~a%, ~a%, ~a%)\">\n"
          (* 100 r) (* 100 g) (* 100 b)))
 
 ;; rotate around given point