Commits

Manfred Moitzi  committed c8cd10c

added example; corrected typos

  • Participants
  • Parent commits 90914ef

Comments (0)

Files changed (6)

 NEWS
 ====
 
-Version 1.0.1 - 08.06.2012
+Version 1.0.2 - ... 2012
+
+  * BUGFIX: dwg.animateTranform() -> dwg.animateTransform()
+  * added examples
+  * edit docs
+
+Version 1.0.1 - 08 June 2012
 
   * added inline stylesheets
   * added examples created by Lawrence Tattrie

File doc/index.rst

 
 Welcome! This is the documentation for svgwrite |version|, last updated |today|.
 
+If you are looking for a SVG Documentation beyond the official W3C papers, go
+to O'Reilly commons: http://commons.oreilly.com/wiki/index.php/SVG_Essentials,
+ or (german) http://www.selfsvg.info .
+
 Contents
 --------
 

File doc/reference.rst

 * SVG on Wikibooks (de): http://de.wikibooks.org/wiki/Svg
 * SVG Authoring Guidelines: http://jwatt.org/svg/authoring/ by Jonathan Watt
 
+Additional SVG Documentation
+============================
+
+* O'Reilly commons: http://commons.oreilly.com/wiki/index.php/SVG_Essentials
+* SelfSVG (de): http://www.selfsvg.info
+
 SVG Implementation Status
 =========================
 
 http://pyparsing.wikispaces.com/
 
 Using :mod:`pyparsing.py` for validation of the **transform** attribute and the
-**d** attribute of the <path> element.
+**d** attribute of the <path> element.

File examples/checkerboard.py

+#!/usr/bin/env python
+#coding:utf-8
+# Author:  mozman
+# Purpose: svg example: inline stylesheets, css, viewbox, groups
+# Created: 09.06.2012
+# Copyright (C) 2012, Manfred Moitzi
+# License: GPLv3
+
+import sys
+
+try:
+    import svgwrite
+except ImportError:
+    # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
+    import os
+    sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..'))
+
+if svgwrite.version < (1,0,1):
+    print("This script requires svgwrite 1.0.1 or newer for internal stylesheets.")
+    sys.exit()
+
+BOARD_WIDTH = "10cm"
+BOARD_HEIGHT = "10cm"
+BOARD_SIZE = (BOARD_WIDTH, BOARD_HEIGHT)
+CSS_STYLES = """
+    .line { stroke: firebrick; stroke-width: .1mm; }
+    .blacksquare { fill: indigo; }
+    .whitesquare { fill: hotpink; }
+"""
+
+def draw_board(dwg):
+    def draw_lines():
+        lines = dwg.add(dwg.g(class_="line"))
+        for i in range(9):
+            y = i * 10
+            lines.add(dwg.line(start=(0, y), end=(80, y)))
+            x = i * 10
+            lines.add(dwg.line(start=(x, 0), end=(x, 80)))
+
+    def draw_squares():
+        white_squares = dwg.add(dwg.g(class_="whitesquare"))
+        black_squares = dwg.add(dwg.g(class_="blacksquare"))
+        for x in range(8):
+            for y in range (8):
+                xc = x * 10 + 1
+                yc = y * 10 + 1
+                square = dwg.rect(insert=(xc, yc), size=(8, 8))
+                (white_squares if (x+y) % 2 else black_squares).add(square)
+    draw_lines()
+    draw_squares()
+
+
+def main():
+    dwg = svgwrite.Drawing('checkerboard.svg', size=BOARD_SIZE)
+    dwg.viewbox(0, 0, 80, 80)
+    # checkerboard has a size of 10cm x 10cm;
+    # defining a viewbox with the size of 80x80 means, that a length of 1
+    # is 10cm/80 == 0.125cm (which is for now the famous USER UNIT)
+    # but I don't have to care about it, I just draw 8x8 squares, each 10x10 USER-UNITS
+
+    # always use css for styling
+    dwg.defs.add(dwg.style(CSS_STYLES))
+    draw_board(dwg)
+    dwg.save()
+
+if __name__== '__main__':
+    main()

File svgwrite/__init__.py

 
 """
 
-version = (1, 0, 1)
+version = (1, 0, 2)
 VERSION = '%d.%d.%d' % version
 
 AUTHOR_NAME = 'Manfred Moitzi'
         self._unit=unit
 
     def __rmul__(self, other):
-        """ add unit-strint to 'other'. (e.g. 5*cm => '5cm') """
+        """ add unit-string to 'other'. (e.g. 5*cm => '5cm') """
         return "%s%s" % (other, self._unit)
 
     def __call__(self, *args):

File svgwrite/elementfactory.py

     'set': animate.Set,
     'animateColor': animate.AnimateColor,
     'animateMotion': animate.AnimateMotion,
-    'animateTranform': animate.AnimateTransform,
+    'animateTransform': animate.AnimateTransform,
     'filter': filters.Filter,
 }