Skip to content

Commit

Permalink
textArea and SVG 1.2 patch from ecmars...@gmail.com
Browse files Browse the repository at this point in the history
  • Loading branch information
wm.annis committed Feb 22, 2011
1 parent d0ad016 commit 379796b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.02 - ???
0.02 - June 15 2008
* fixed duplicate :text-length in XMLIFY-KEYWORD (format-xml.lisp)
* added ADD-NAMESPACE method, available to all elements (svg.lisp)
* added SCRIPT-LINK function (svg.lisp)
Expand Down
6 changes: 3 additions & 3 deletions package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#:missing-attributes
#:stream-out
#:xlink-href
#:svg-toplevel #:svg-1.1-toplevel
#:svg-toplevel #:svg-1.1-toplevel #:svg-1.2-toplevel
#:make-svg-toplevel
#:with-svg-to-file
#:add-stylesheet
Expand All @@ -49,7 +49,7 @@
#:script
#:script-link
#:style
#:text
#:text #:textarea
#:tspan
#:make-svg-symbol
#:make-marker
Expand Down Expand Up @@ -85,4 +85,4 @@
#:arc-to #:arc-to-r
#:close-path))

;;; package.lisp ends here
;;; package.lisp ends here
23 changes: 22 additions & 1 deletion svg.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ contents the new transform is simply appended."))
"xmlns" "http://www.w3.org/2000/svg"
"xmlns:xlink" "http://www.w3.org/1999/xlink")))

(defclass svg-1.2-toplevel (svg-toplevel)
()
(:default-initargs
:name "svg"
:xml-header "<?xml version=\"1.0\" standalone=\"no\"?>"
:attributes (list :version "1.2" :id "toplevel"
"xmlns" "http://www.w3.org/2000/svg"
"xmlns:xlink" "http://www.w3.org/1999/xlink")))


(defun make-svg-toplevel (class &rest attributes)
(let ((svg (make-instance class)))
;; Merge with, don't clobber, <svg /> attributes.
Expand All @@ -198,7 +208,8 @@ contents the new transform is simply appended."))
(format s "~A~&" (slot-value e 'xml-header))
(dolist (css (slot-value e 'stylesheets))
(format s "<?xml-stylesheet href=\"~A\" type=\"text/css\"?>~&" css))
(format s "~A~&" (slot-value e 'doctype))
(when (slot-boundp e 'doctype)
(format s "~A~&" (slot-value e 'doctype)))
(with-xml-group-element (s (element-name e) (element-attributes e))
(when (has-contents-p (svg-defs e))
(stream-out s (svg-defs e)))
Expand Down Expand Up @@ -385,6 +396,16 @@ contents the new transform is simply appended."))
(add-element ,group element))
,group)))

(define-element-maker :textarea "textArea" '(:x :y :width :height))

(defmacro textarea (scene (&rest opts) &body elements)
(let ((group (gensym "group")))
`(let ((,group (make-svg-element :text (list ,@opts))))
(add-element ,scene ,group)
(dolist (element (list ,@elements))
(add-element ,group element))
,group)))


;;; Gradients.
(defun gradient-stop (&key color offset (opacity 1.0))
Expand Down
10 changes: 5 additions & 5 deletions testing.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ great colors. And the random rectangles! You want this as wallpaper.")
(root canvas x y angle (1- depth) alpha))))

(let* ((scene (make-svg-toplevel 'svg-1.1-toplevel :height 700 :width 700
:viewbox "0 0 700 700"))
:view-box "0 0 700 700"))
(rg (make-radial-gradient scene (:id :generate
:cx "50%" :cy "50%" :r "50%")
(stop :color "rgb(32, 38, 0)" :offset "0%")
Expand All @@ -268,7 +268,7 @@ great colors. And the random rectangles! You want this as wallpaper.")

;;; paths - an example from the SVG spec
(let* ((scene (make-svg-toplevel 'svg-1.1-toplevel :height 700 :width 700
:viewbox "0 0 700 700")))
:view-box "0 0 700 700")))
(title scene "Path test")
(draw scene (:path :d (path
(move-to 100 400)
Expand All @@ -288,7 +288,7 @@ great colors. And the random rectangles! You want this as wallpaper.")

;;; Some random curves.
(let* ((scene (make-svg-toplevel 'svg-1.1-toplevel :height 700 :width 700
:viewbox "0 0 700 700"))
:view-box "0 0 700 700"))
(rg (make-radial-gradient scene (:id :generate
:cx "50%" :cy "50%" :r "50%")
(stop :color "rgb(32, 38, 0)" :offset "0%")
Expand Down Expand Up @@ -349,7 +349,7 @@ great colors. And the random rectangles! You want this as wallpaper.")
(incf angle c)))))

(let* ((scene (make-svg-toplevel 'svg-1.1-toplevel :height 700 :width 700
:viewbox "0 0 700 700"))
:view-box "0 0 700 700"))
(rg (make-radial-gradient scene (:id :generate
:cx "50%" :cy "50%" :r "50%")
(stop :color "rgb(32, 38, 0)" :offset "0%")
Expand Down Expand Up @@ -397,4 +397,4 @@ on <tt>foreignObject</tt>s, too.</p>")
(add-element fo2 "</body>")))


;;; testing.lisp ends here
;;; testing.lisp ends here

0 comments on commit 379796b

Please sign in to comment.