X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Foutput-svg.scm;h=80199a1f952871334a18b8dd595e38152c59ba9d;hb=b97565a9af1c13369ac7e7e9ea80c2638dbc0e51;hp=51a491a8ef5d4d07277a952fb31fb5327b92e40d;hpb=b3b57cf54210b7f4766a656d2c6ab36e2106df76;p=lilypond.git diff --git a/scm/output-svg.scm b/scm/output-svg.scm index 51a491a8ef..80199a1f95 100644 --- a/scm/output-svg.scm +++ b/scm/output-svg.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2002--2006 Jan Nieuwenhuizen +;;;; (c) 2002--2009 Jan Nieuwenhuizen ;;;; http://www.w3.org/TR/SVG11 ;;;; http://www.w3.org/TR/SVG12/ -- page, pageSet in draft @@ -107,6 +107,9 @@ (apply string-append (map (lambda (x) (char->entity x)) (string->list string)))) +(define svg-element-regexp + (make-regexp "^(<[a-z]+) (.*>)")) + (define pango-description-regexp-comma (make-regexp "([^,]+), ?([-a-zA-Z_]*) ([0-9.]+)$")) @@ -280,12 +283,18 @@ (ly:font-glyph-name-to-charcode font name)))))) (define (placebox x y expr) - (entity 'g - expr - ;; FIXME: Not using GNU coding standards [translate ()] here - ;; to work around a bug in Microsoft Internet Explorer 6.0 - `(transform . ,(ly:format "translate(~f, ~f)" - x (- y))))) + (let* + ((match (regexp-exec svg-element-regexp expr)) + (tagname (match:substring match 1)) + (attributes (match:substring match 2))) + + (string-append tagname + ;; FIXME: Not using GNU coding standards + ;; [translate ()] here to work around a + ;; bug in Microsoft Internet Explorer 6.0 + (ly:format " transform=\"translate(~f, ~f)\" " x (- y)) + attributes + "\n"))) (define (polygon coords blot-diameter is-filled) (entity @@ -301,13 +310,13 @@ ;; rotate around given point (define (setrotation ang x y) - (format "" + (format "\n" (number->string (* -1 ang)) (number->string x) (number->string (* -1 y)))) (define (resetrotation ang x y) - "") + "\n") (define (round-filled-box breapth width depth height blot-diameter) (entity 'rect "" @@ -336,6 +345,37 @@ `(stroke-width . ,thick) `(r . ,radius))) +(define (ellipse x-radius y-radius thick is-filled) + (entity + 'ellipse "" + '(stroke-linejoin . "round") + '(stroke-linecap . "round") + `(fill . ,(if is-filled "currentColor" "none")) + `(stroke . "currentColor") + `(stroke-width . ,thick) + `(rx . ,x-radius) + `(ry . ,y-radius))) + +(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,~4f C~4f,~4f ~4f,~4f ~4f,~4f S~4f,~4f ~4f,~4f" + x-max 0 + x-max y-max + x-min y-max + x-min 0 + x-max y-min + x-max 0))))) + (define (text font string) (dispatch `(fontify ,font ,(entity 'tspan (string->entities string))))) @@ -345,9 +385,9 @@ (define (setcolor r g b) - (format "" + (format "\n" (* 100 r) (* 100 g) (* 100 b) )) (define (resetcolor) - "") + "\n")