Manfred Moitzi avatar Manfred Moitzi committed dd8947d

created mixins module; additional docs;

Comments (0)

Files changed (5)

doc/classes/drawing.rst

 
    `string` should be valid for :func:`open`.
 
+Methods
+-------
+
+.. automethod:: svgwrite.drawing.Drawing.write(fileobj)
+
+.. automethod:: svgwrite.drawing.Drawing.save()
+
+.. automethod:: svgwrite.drawing.Drawing.saveas(filename)
+
+.. automethod:: svgwrite.drawing.Drawing.add_stylesheet(href, title, alternate, media)
+
+.. automethod:: svgwrite.drawing.Drawing.get_xml()
+
+Factory Methods
+---------------
+
+.. method:: Drawing.line(start=(0, 0), end=(0, 0), attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.shapes.Line` object.
+
+.. method:: Drawing.rect(insert=(0, 0), size=(1, 1), rx=None, ry=None, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.shapes.Rect` object.
+
+.. method:: Drawing.circle(center=(0, 0), r=1, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.shapes.Circle` object.
+
+.. method:: Drawing.ellipse(center=(0, 0), r=(1, 1), attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.shapes.Ellipse` object.
+
+.. method:: Drawing.polyline(points=[], attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.shapes.Polyline` object.
+
+.. method:: Drawing.polygon(points=[], attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.shapes.Polygon` object.
+
+.. method:: Drawing.text(text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[], attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.text.Text` object.
+
+.. method:: Drawing.tspan(text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[], attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.text.TSpan` object.
+
+.. method:: Drawing.tref(element, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.text.TRef` object.
+
+.. method:: Drawing.textPath(path, text, startOffset=None, method='align', spacing='exact', attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.text.TextPath` object.
+
+.. method:: Drawing.textArea(text=None, insert=None, size=None, attribs={}, \*\*extra)
+
+   Create a :class:`svgwrite.text.TextArea` object.
+
+.. method:: Drawing.path(d=None, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.path.Path` object.
+
+.. method:: Drawing.image(href, insert=None, size=None, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.image.Image` object.
+
+.. method:: Drawing.g(attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.container.Group` object.
+
+.. method:: Drawing.defs(attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.container.Defs` object.
+
+.. method:: Drawing.symbol(attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.container.Symbol` object.
+
+.. method:: Drawing.svg(insert=None, size=None, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.container.SVG` object.
+
+.. method:: Drawing.use(href, insert=None, size=None, attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.container.Use` object.
+
+.. method:: Drawing.a(href, target='_blank', attribs=None, \*\*extra)
+
+   Create a :class:`svgwrite.container.Hyperlink` object.
+
 Inherited Attributes
 --------------------
 
 
    *Defs* container for referenced SVG elements
 
-Methods
--------
-
-.. automethod:: svgwrite.drawing.Drawing.write(fileobj)
-
-.. automethod:: svgwrite.drawing.Drawing.save()
-
-.. automethod:: svgwrite.drawing.Drawing.saveas(filename)
-
-.. automethod:: svgwrite.drawing.Drawing.add_stylesheet(href, title, alternate, media)
-
-.. automethod:: svgwrite.drawing.Drawing.get_xml()
-
 Inherited Methods
 -----------------
 

doc/classes/mixins.rst

+:class:`Presentation` mixin
+===========================
+
+.. autoclass:: svgwrite.mixins.Presentation
+
+Methods
+-------
+
+.. automethod:: svgwrite.mixins.Presentation.fill(color=None, rule=None, opacity=None)
+
+.. seealso::
+
+   * http://www.w3.org/TR/SVG11/painting.html#FillProperty
+   * http://www.w3.org/TR/SVG11/painting.html#FillRuleProperty
+   * http://www.w3.org/TR/SVG11/painting.html#FillOpacityProperty
+
+.. automethod:: svgwrite.mixins.Presentation.stroke(color=None, width=None, opacity=None, linecap=None, linejoin=None, miterlimit=None)
+
+.. seealso::
+
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeProperty
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeWidthProperty
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeOpacityProperty
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeLinecapProperty
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty
+
+.. automethod:: svgwrite.mixins.Presentation.dasharray(definition=None, offset=None)
+
+.. seealso::
+
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeArrayProperty
+   * http://www.w3.org/TR/SVG11/painting.html#StrokeDashoffsetProperty
+
+.. automethod:: svgwrite.mixins.Presentation.viewport_fill(color=None, opacity=None)
+
+   only SVG 1.2 Tiny
+
+.. seealso::
+
+   * http://www.w3.org/TR/SVGMobile12/painting.html#viewport-fill-property
+   * http://www.w3.org/TR/SVGMobile12/painting.html#viewport-fill-opacity-property
+
 
    classes/interface
 
+Mixins
+------
+
+.. toctree::
+   :maxdepth: 1
+
+   classes/mixins
+
 Indices and tables
 ==================
 

svgwrite/interface.py

         else:
             idstr = self.href.attribs.setdefault('id', self.nextid())
         self.attribs['xlink:href'] =  "#%s" % idstr
-
-class IPresentation(object):
-    """
-    Helper methods to set presentation attributes.
-    """
-    def fill(self, color=None, rule=None, opacity=None):
-        if color:
-            self['fill'] = color
-        if rule:
-            self['fill-rule'] = rule
-        if opacity:
-            self['fill-opacity'] = opacity
-
-    def stroke(self, color=None, width=None, opacity=None, linecap=None,
-               linejoin=None, miterlimit=None):
-        if color:
-            self['stroke'] = color
-        if width:
-            self['stroke-width'] = width
-        if opacity:
-            self['stroke-opacity'] = opacity
-        if linecap:
-            self['stroke-linecap'] = linecap
-        if join:
-            self['stroke-linejoin'] = linejoin
-        if miterlimit:
-            self['stroke-miterlimit'] = miterlimit
-
-    def dasharray(self, definition=None, offset=None):
-        if definition:
-            self['stroke-array'] = definition
-        if offset:
-            self['stroke-dashoffset'] = offset
-
-    def viewport_fill(self, color=None, opacity=None):
-        if color:
-            self['viewport-fill'] = color
-        if opacity:
-            self['viewport-fill-opacity'] = opacity

svgwrite/mixins.py

+#!/usr/bin/env python
+#coding:utf-8
+# Author:  mozman --<mozman@gmx.at>
+# Purpose: mixins
+# Created: 19.10.2010
+# Copyright (C) 2010, Manfred Moitzi
+# License: GPLv3
+
+class Presentation(object):
+    """
+    Helper methods to set presentation attributes.
+    """
+    def fill(self, color=None, rule=None, opacity=None):
+        """
+        Set SVG Properties **fill**, **fill-rule** and **fill-opacity**.
+
+        """
+        if color:
+            self['fill'] = color
+        if rule:
+            self['fill-rule'] = rule
+        if opacity:
+            self['fill-opacity'] = opacity
+
+    def stroke(self, color=None, width=None, opacity=None, linecap=None,
+               linejoin=None, miterlimit=None):
+        """
+        Set SVG Properties **stroke**, **stroke-width**, **stroke-opacity**,
+        **stroke-linecap** and **stroke-miterlimit**.
+
+        """
+
+        if color:
+            self['stroke'] = color
+        if width:
+            self['stroke-width'] = width
+        if opacity:
+            self['stroke-opacity'] = opacity
+        if linecap:
+            self['stroke-linecap'] = linecap
+        if linejoin:
+            self['stroke-linejoin'] = linejoin
+        if miterlimit:
+            self['stroke-miterlimit'] = miterlimit
+
+    def dasharray(self, definition=None, offset=None):
+        """
+        Set SVG Properties **stroke-dashoffset** and **stroke-array**.
+
+        """
+        if definition:
+            self['stroke-array'] = definition
+        if offset:
+            self['stroke-dashoffset'] = offset
+
+    def viewport_fill(self, color=None, opacity=None):
+        """
+        Set SVG Properties **viewport-fill** and **viewport-fill-opacity**.
+
+        """
+        if color:
+            self['viewport-fill'] = color
+        if opacity:
+            self['viewport-fill-opacity'] = opacity
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.