[Python-modules-commits] [svgwrite] 01/02: Imported Upstream version 1.1.8
Steffen Möller
moeller at moszumanska.debian.org
Wed Jun 29 13:56:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
moeller pushed a commit to branch master
in repository svgwrite.
commit eb27bfeb2becc3f951f5d52e1519d0bc5ccd2cc3
Author: Steffen Moeller <moeller at debian.org>
Date: Wed Jun 29 13:29:56 2016 +0200
Imported Upstream version 1.1.8
---
LICENSE.TXT | 45 +
MANIFEST.in | 4 +
NEWS.rst | 109 ++
PKG-INFO | 196 +++
README.rst | 63 +
examples/LSystem.py | 112 ++
examples/basic_shapes.py | 43 +
examples/checkerboard.py | 73 ++
examples/defs_test.py | 78 ++
examples/fePointLight.py | 36 +
examples/koch_snowflake.py | 115 ++
examples/linearGradient.py | 80 ++
examples/ltattrie/bezier.py | 134 +++
examples/ltattrie/circle_blur.py | 50 +
examples/ltattrie/color_names.py | 195 +++
examples/ltattrie/color_triangles_function.py | 97 ++
examples/ltattrie/length_units.py | 64 +
examples/ltattrie/line_cap_join.py | 54 +
examples/ltattrie/rgb.txt | 949 +++++++++++++++
examples/ltattrie/runall.bat | 2 +
examples/ltattrie/runall.sh | 7 +
examples/ltattrie/runall3.bat | 2 +
examples/ltattrie/tenticles.py | 311 +++++
examples/ltattrie/text_font_generic_family.py | 42 +
examples/ltattrie/text_font_size.py | 50 +
examples/ltattrie/text_justify.py | 40 +
examples/ltattrie/tiling_part_1.py | 289 +++++
examples/ltattrie/tiling_part_2.py | 352 ++++++
examples/ltattrie/tiling_part_3.py | 477 ++++++++
examples/ltattrie/tiling_part_4.py | 394 ++++++
examples/ltattrie/tiling_part_5.py | 332 +++++
examples/ltattrie/xkcd_colour_data_svgwrite_3.py | 107 ++
examples/mandelbrot.py | 60 +
examples/marker.py | 82 ++
examples/pattern.py | 30 +
examples/radialGradient.py | 39 +
examples/runall.bat | 2 +
examples/runall.sh | 7 +
examples/runall3.bat | 2 +
examples/runallpypy.bat | 2 +
examples/simple_text.py | 43 +
examples/use.py | 48 +
requirements.txt | 1 +
setup.cfg | 5 +
setup.py | 52 +
svgwrite.egg-info/PKG-INFO | 196 +++
svgwrite.egg-info/SOURCES.txt | 130 ++
svgwrite.egg-info/dependency_links.txt | 1 +
svgwrite.egg-info/requires.txt | 1 +
svgwrite.egg-info/top_level.txt | 2 +
svgwrite/__init__.py | 90 ++
svgwrite/animate.py | 180 +++
svgwrite/base.py | 268 +++++
svgwrite/container.py | 243 ++++
svgwrite/data/__init__.py | 0
svgwrite/data/colors.py | 156 +++
svgwrite/data/full11.py | 1406 ++++++++++++++++++++++
svgwrite/data/pattern.py | 30 +
svgwrite/data/svgparser.py | 161 +++
svgwrite/data/tiny12.py | 966 +++++++++++++++
svgwrite/data/typechecker.py | 336 ++++++
svgwrite/data/types.py | 79 ++
svgwrite/drawing.py | 120 ++
svgwrite/elementfactory.py | 74 ++
svgwrite/etree.py | 49 +
svgwrite/filters.py | 273 +++++
svgwrite/gradients.py | 130 ++
svgwrite/image.py | 61 +
svgwrite/masking.py | 50 +
svgwrite/mixins.py | 295 +++++
svgwrite/params.py | 71 ++
svgwrite/path.py | 90 ++
svgwrite/pattern.py | 50 +
svgwrite/shapes.py | 172 +++
svgwrite/text.py | 218 ++++
svgwrite/utils.py | 227 ++++
svgwrite/validator2.py | 167 +++
tests/__init__.py | 0
tests/test_animate.py | 114 ++
tests/test_animation_timing_parser.py | 66 +
tests/test_base_element.py | 86 ++
tests/test_circle.py | 30 +
tests/test_clippath.py | 30 +
tests/test_clipping.py | 29 +
tests/test_clock_val_parser.py | 70 ++
tests/test_defs.py | 31 +
tests/test_description.py | 77 ++
tests/test_drawing.py | 111 ++
tests/test_elementfactory.py | 81 ++
tests/test_ellipse.py | 32 +
tests/test_filters.py | 414 +++++++
tests/test_full11_typechecker.py | 367 ++++++
tests/test_gradients.py | 77 ++
tests/test_group.py | 32 +
tests/test_hyperlink.py | 27 +
tests/test_image.py | 53 +
tests/test_line.py | 36 +
tests/test_marker_class.py | 49 +
tests/test_markers_mixin.py | 57 +
tests/test_mask.py | 25 +
tests/test_mediagroup.py | 25 +
tests/test_parameter.py | 28 +
tests/test_parsing_basic_types.py | 116 ++
tests/test_path.py | 61 +
tests/test_pathdataparser.py | 143 +++
tests/test_pattern.py | 36 +
tests/test_polyline.py | 75 ++
tests/test_presentation.py | 82 ++
tests/test_rect.py | 40 +
tests/test_script.py | 28 +
tests/test_style.py | 20 +
tests/test_svg.py | 27 +
tests/test_svgattributes.py | 77 ++
tests/test_symbol.py | 31 +
tests/test_text.py | 93 ++
tests/test_textarea.py | 89 ++
tests/test_tiny12_typechecker.py | 60 +
tests/test_transform.py | 126 ++
tests/test_transformlistparser.py | 68 ++
tests/test_use.py | 44 +
tests/test_utils.py | 185 +++
tests/test_validator2.py | 145 +++
tests/test_viewbox.py | 59 +
tests/test_xlink.py | 70 ++
124 files changed, 15189 insertions(+)
diff --git a/LICENSE.TXT b/LICENSE.TXT
new file mode 100644
index 0000000..836ed0b
--- /dev/null
+++ b/LICENSE.TXT
@@ -0,0 +1,45 @@
+Copyright (c) 2012, Manfred Moitzi
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Deutsche Übersetzung:
+
+Copyright (c) 2012, Manfred Moitzi
+
+Hiermit wird unentgeltlich, jeder Person, die eine Kopie der Software
+und der zugehörigen Dokumentationen (die "Software") erhält, die
+Erlaubnis erteilt, uneingeschränkt zu benutzen, inklusive und ohne
+Ausnahme, dem Recht, sie zu verwenden, kopieren, ändern, fusionieren,
+verlegen, verbreiten, unterlizenzieren und/oder zu verkaufen, und
+Personen, die diese Software erhalten, diese Rechte zu geben, unter den
+folgenden Bedingungen:
+
+Der obige Urheberrechtsvermerk und dieser Erlaubnisvermerk sind in allen
+Kopien oder Teilkopien der Software beizulegen.
+
+DIE SOFTWARE WIRD OHNE JEDE AUSDRÜCKLICHE ODER IMPLIZIERTE GARANTIE
+BEREITGESTELLT, EINSCHLIESSLICH DER GARANTIE ZUR BENUTZUNG FÜR DEN
+VORGESEHENEN ODER EINEM BESTIMMTEN ZWECK SOWIE JEGLICHER
+RECHTSVERLETZUNG, JEDOCH NICHT DARAUF BESCHRÄNKT. IN KEINEM FALL SIND
+DIE AUTOREN ODER COPYRIGHTINHABER FÜR JEGLICHEN SCHADEN ODER SONSTIGE
+ANSPRÜCHE HAFTBAR ZU MACHEN, OB INFOLGE DER ERFÜLLUNG EINES VERTRAGES,
+EINES DELIKTES ODER ANDERS IM ZUSAMMENHANG MIT DER SOFTWARE ODER
+SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN.
+
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..60678d3
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,4 @@
+include NEWS.rst README.rst LICENSE.TXT
+include requirements.txt
+recursive-include examples *.py *.bat *.sh *.txt
+recursive-include tests *.py
diff --git a/NEWS.rst b/NEWS.rst
new file mode 100644
index 0000000..8fe45c8
--- /dev/null
+++ b/NEWS.rst
@@ -0,0 +1,109 @@
+
+NEWS
+====
+
+Version 1.1.8 - 2016-05-31
+
+ * BUGFIX: None checks: 'if value:' -> 'if value is not None:'
+
+Version 1.1.7 - 2016-05-22
+
+ * BUGFIX: color accepts percentage values as floats like "rgb(10.2%, 3.78%, 20%)"
+
+Version 1.1.6 - 2014-05-30
+
+ * BUGFIX: sign for offset-value wasn't optional
+
+Version 1.1.5 - 2014-03-26
+
+ * BUGFIX: xml serialization for CPython 3.4.0
+
+Version 1.1.4 - 2014-03-16
+
+ * simplified path parser
+ * pyparsing as external dependency (by jenselme)
+
+Version 1.1.3 - 2013-10-01
+
+ * updated pyparsing for Python 3 to version 2.0.1 (prior version caused memory leaks)
+ * BUGFIX: utf8 to unicode encoding error for Python 2.7
+ * Tests for Python 3 require CPython3.3 or newer, using the 'u' prefix.
+
+Version 1.1.2 - 2013-01-08
+
+ * prevent setup.py from compiling all modules - error with 'pyparsing_py2.py' and Python3
+ * BUGFIX: all tests run with CPython3.3
+
+Version 1.1.1 - 2012-08-15
+
+ * License changed to MIT License
+ * tested with CPython2.7, CPython3.2, CPython3.3 and pypy-1.9 on Win7 Pro 32-bit
+ * BUGFIX: dwg.animateTranform() -> dwg.animateTransform()
+ * BUGFIX: in examples, replaced width and height params by size parameter
+ * added examples
+ * edit docs
+
+Version 1.0.1 - 2012-06-08
+
+ * added inline stylesheets
+ * added examples created by Lawrence Tattrie
+
+Version 1.0.0 - 2012-05-27
+
+ * stable
+ * tested with CPython 2.7, CPython 3.2, pypy-1.8
+ * added script tag - thx to jmahmood
+ * docs also available at: http://readthedocs.org/docs/svgwrite
+
+Version 0.2.4 - 2011-12-30
+
+ * beta version
+ * Python 2.7: all strings will be converted by the unicode() function, for
+ strings containing none-ascii-characters use prefix ``u""`` or better
+ use ``from __future__ import unicode_literals``, because this is
+ Python 3 compatible.
+ * tested with CPython 2.7, CPython 3.2, and PyPy 1.7
+ * BUGFIX: color parsing accepts white spaces in ``rgb()`` like ``rgb(0, 0, 0)``
+
+Version 0.2.3 - 2010-11-13
+
+ * beta version
+ * Python 3.1 support
+ * splitted examples.py into several files and moved them to
+ the subdir 'examples'
+
+Version 0.2.2 - 2010-11-05
+
+ * alpha version
+ * removed 'attribs' parameter from all constructors
+ * new elements: Set, Animate, AnimateMotion, AnimateColor,
+ AnimateTransform, all filter elements
+ * added set_desc(title, desc), set_metadata(xmldata) to BaseElement class
+ * moved content of interfaces.py to mixins.py, (ITransform -> Transform and so on)
+
+Version 0.2.1 - 2010-10-31
+
+ * alpha version
+ * new elements: Marker, ClipPath, Mask
+ * paint service: LinearGradient, RadialGradient, Pattern
+
+Version 0.2.0 - 2010-10-24
+
+ * alpha version
+ * validator rewritten as validator2.py
+ * debug and profile options separated for each drawing object
+ * important change: create objects with factory functions of the
+ *Drawing* class: drawing.<svg-elementname>(...)
+ * added mixins for setting stroke and fill properties
+ * new elements: Hyperlink, Image, TextArea,
+
+Version 0.1.0 - 2010-09-26
+
+ * alpha version
+ * new elements:
+
+ * basic shapes: Line, Rect, Circle, Ellipse, Polyline, Polygon, Path
+ * text elements: Text, TSpan, TRef, TextPath
+ * container elements: Group, Symbol, SVG, Use, Defs
+
+ * for examples see: examples.py
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..09235c1
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,196 @@
+Metadata-Version: 1.1
+Name: svgwrite
+Version: 1.1.8
+Summary: A Python library to create SVG drawings.
+Home-page: http://bitbucket.org/mozman/svgwrite
+Author: Manfred Moitzi
+Author-email: mozman at gmx.at
+License: MIT License
+Download-URL: http://bitbucket.org/mozman/svgwrite/downloads
+Description:
+ svgwrite
+ ========
+
+ .. image:: https://readthedocs.org/projects/pip/badge/
+ :target: https://svgwrite.readthedocs.io
+ :alt: Read The Docs
+
+ .. image:: https://img.shields.io/pypi/l/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: License
+
+ .. image:: https://img.shields.io/pypi/pyversions/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: Python Versions
+
+ .. image:: https://img.shields.io/pypi/wheel/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: Wheel Status
+
+ .. image:: https://img.shields.io/pypi/status/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: Status
+
+ Abstract
+ ========
+
+ A Python library to create SVG drawings.
+
+ a simple example::
+
+ import svgwrite
+
+ dwg = svgwrite.Drawing('test.svg', profile='tiny')
+ dwg.add(dwg.line((0, 0), (10, 0), stroke=svgwrite.rgb(10, 10, 16, '%')))
+ dwg.add(dwg.text('Test', insert=(0, 0.2), fill='red'))
+ dwg.save()
+
+ for more examples see: examples.py
+
+ Installation
+ ============
+
+ with pip::
+
+ pip install svgwrite
+
+ or from source::
+
+ python setup.py install
+
+
+ Documentation
+ =============
+
+ * http://packages.python.org/svgwrite
+ * http://readthedocs.org/docs/svgwrite/
+
+ send feedback to mozman at gmx.at
+
+ svgwrite can be found on bitbucket.org at:
+
+ http://bitbucket.org/mozman/svgwrite
+
+ NEWS
+ ====
+
+ Version 1.1.8 - 2016-05-31
+
+ * BUGFIX: None checks: 'if value:' -> 'if value is not None:'
+
+ Version 1.1.7 - 2016-05-22
+
+ * BUGFIX: color accepts percentage values as floats like "rgb(10.2%, 3.78%, 20%)"
+
+ Version 1.1.6 - 2014-05-30
+
+ * BUGFIX: sign for offset-value wasn't optional
+
+ Version 1.1.5 - 2014-03-26
+
+ * BUGFIX: xml serialization for CPython 3.4.0
+
+ Version 1.1.4 - 2014-03-16
+
+ * simplified path parser
+ * pyparsing as external dependency (by jenselme)
+
+ Version 1.1.3 - 2013-10-01
+
+ * updated pyparsing for Python 3 to version 2.0.1 (prior version caused memory leaks)
+ * BUGFIX: utf8 to unicode encoding error for Python 2.7
+ * Tests for Python 3 require CPython3.3 or newer, using the 'u' prefix.
+
+ Version 1.1.2 - 2013-01-08
+
+ * prevent setup.py from compiling all modules - error with 'pyparsing_py2.py' and Python3
+ * BUGFIX: all tests run with CPython3.3
+
+ Version 1.1.1 - 2012-08-15
+
+ * License changed to MIT License
+ * tested with CPython2.7, CPython3.2, CPython3.3 and pypy-1.9 on Win7 Pro 32-bit
+ * BUGFIX: dwg.animateTranform() -> dwg.animateTransform()
+ * BUGFIX: in examples, replaced width and height params by size parameter
+ * added examples
+ * edit docs
+
+ Version 1.0.1 - 2012-06-08
+
+ * added inline stylesheets
+ * added examples created by Lawrence Tattrie
+
+ Version 1.0.0 - 2012-05-27
+
+ * stable
+ * tested with CPython 2.7, CPython 3.2, pypy-1.8
+ * added script tag - thx to jmahmood
+ * docs also available at: http://readthedocs.org/docs/svgwrite
+
+ Version 0.2.4 - 2011-12-30
+
+ * beta version
+ * Python 2.7: all strings will be converted by the unicode() function, for
+ strings containing none-ascii-characters use prefix ``u""`` or better
+ use ``from __future__ import unicode_literals``, because this is
+ Python 3 compatible.
+ * tested with CPython 2.7, CPython 3.2, and PyPy 1.7
+ * BUGFIX: color parsing accepts white spaces in ``rgb()`` like ``rgb(0, 0, 0)``
+
+ Version 0.2.3 - 2010-11-13
+
+ * beta version
+ * Python 3.1 support
+ * splitted examples.py into several files and moved them to
+ the subdir 'examples'
+
+ Version 0.2.2 - 2010-11-05
+
+ * alpha version
+ * removed 'attribs' parameter from all constructors
+ * new elements: Set, Animate, AnimateMotion, AnimateColor,
+ AnimateTransform, all filter elements
+ * added set_desc(title, desc), set_metadata(xmldata) to BaseElement class
+ * moved content of interfaces.py to mixins.py, (ITransform -> Transform and so on)
+
+ Version 0.2.1 - 2010-10-31
+
+ * alpha version
+ * new elements: Marker, ClipPath, Mask
+ * paint service: LinearGradient, RadialGradient, Pattern
+
+ Version 0.2.0 - 2010-10-24
+
+ * alpha version
+ * validator rewritten as validator2.py
+ * debug and profile options separated for each drawing object
+ * important change: create objects with factory functions of the
+ *Drawing* class: drawing.<svg-elementname>(...)
+ * added mixins for setting stroke and fill properties
+ * new elements: Hyperlink, Image, TextArea,
+
+ Version 0.1.0 - 2010-09-26
+
+ * alpha version
+ * new elements:
+
+ * basic shapes: Line, Rect, Circle, Ellipse, Polyline, Polygon, Path
+ * text elements: Text, TSpan, TRef, TextPath
+ * container elements: Group, Symbol, SVG, Use, Defs
+
+ * for examples see: examples.py
+
+Platform: OS Independent
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Intended Audience :: Developers
+Classifier: Topic :: Multimedia :: Graphics
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Provides: svgwrite
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..150d0ee
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,63 @@
+
+svgwrite
+========
+
+.. image:: https://readthedocs.org/projects/pip/badge/
+ :target: https://svgwrite.readthedocs.io
+ :alt: Read The Docs
+
+.. image:: https://img.shields.io/pypi/l/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: License
+
+.. image:: https://img.shields.io/pypi/pyversions/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: Python Versions
+
+.. image:: https://img.shields.io/pypi/wheel/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: Wheel Status
+
+.. image:: https://img.shields.io/pypi/status/svgwrite.svg
+ :target: https://pypi.python.org/pypi/svgwrite/
+ :alt: Status
+
+Abstract
+========
+
+A Python library to create SVG drawings.
+
+a simple example::
+
+ import svgwrite
+
+ dwg = svgwrite.Drawing('test.svg', profile='tiny')
+ dwg.add(dwg.line((0, 0), (10, 0), stroke=svgwrite.rgb(10, 10, 16, '%')))
+ dwg.add(dwg.text('Test', insert=(0, 0.2), fill='red'))
+ dwg.save()
+
+for more examples see: examples.py
+
+Installation
+============
+
+with pip::
+
+ pip install svgwrite
+
+or from source::
+
+ python setup.py install
+
+
+Documentation
+=============
+
+ * http://packages.python.org/svgwrite
+ * http://readthedocs.org/docs/svgwrite/
+
+send feedback to mozman at gmx.at
+
+svgwrite can be found on bitbucket.org at:
+
+http://bitbucket.org/mozman/svgwrite
diff --git a/examples/LSystem.py b/examples/LSystem.py
new file mode 100644
index 0000000..a32266f
--- /dev/null
+++ b/examples/LSystem.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#coding:utf-8
+# Author: mozman
+# Purpose: svg examples
+# Created: 08.09.2010
+# Copyright (C) 2010, Manfred Moitzi
+# License: MIT License
+
+try:
+ import svgwrite
+except ImportError:
+ # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
+ import sys, os
+ sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..'))
+
+import math
+import svgwrite
+
+LevyDragon = {'length':1, 'numAngle':4, 'level':16, 'init': 'FX',
+ 'target': 'X', 'replacement': 'X+YF+', 'target2': 'Y',
+ 'replacement2': '-FX-Y'}
+
+KochSnowflake = {'length':1, 'numAngle':6, 'level':6, 'init': 'F++F++F',
+ 'target': 'F', 'replacement': 'F-F++F-F', 'target2': '',
+ 'replacement2': ''}
+
+LevyCurve = {'length':1, 'numAngle':8, 'level':17, 'init': 'F',
+ 'target': 'F', 'replacement': '+F--F+', 'target2': '',
+ 'replacement2': ''}
+
+HilbertSpaceFillingCurve = {'length':1, 'numAngle':4, 'level':5, 'init': 'L',
+ 'target': 'L', 'replacement': '+RF-LFL-FR+', 'target2': 'R',
+ 'replacement2': '-LF+RFR+FL-'}
+
+def LSystem(name, formula=LevyCurve):
+ ## {{{ http://code.activestate.com/recipes/577159/ (r1)
+ # L-System Fractals
+ # FB - 201003276
+ # image size
+
+ # generate the fractal drawing string
+ def _LSystem(formula):
+ state = formula['init']
+ target = formula['target']
+ replacement = formula['replacement']
+ target2 = formula['target2']
+ replacement2 = formula['replacement2']
+ level = formula['level']
+
+ for counter in range(level):
+ state2 = ''
+ for character in state:
+ if character == target:
+ state2 += replacement
+ elif character == target2:
+ state2 += replacement2
+ else:
+ state2 += character
+ state = state2
+ return state
+ print("creating: %s\n" % name)
+ xmin, ymin = (100000, 100000)
+ xmax, ymax = (-100000, -100000)
+
+ numAngle = formula['numAngle']
+ length = formula['length']
+ fractal = _LSystem(formula)
+ na = 2.0 * math.pi / numAngle
+ sn = []
+ cs = []
+ for i in range(numAngle):
+ sn.append(math.sin(na * i))
+ cs.append(math.cos(na * i))
+
+ x = 0.0
+ y = 0.0
+
+ # jx = int((x - xa) / (xb - xa) * (imgx - 1))
+ # jy = int((y - ya) / (yb - ya) * (imgy - 1))
+ k = 0
+ dwg = svgwrite.Drawing(name, debug=True)
+ curve = dwg.polyline(points=[(x, y)], stroke='green', fill='none', stroke_width=0.1)
+ for ch in fractal:
+ if ch == 'F':
+ # turtle forward(length)
+ x += length * cs[k]
+ y += length * sn[k]
+
+ curve.points.append( (x, y) )
+
+ # find maxima
+ xmin = min(xmin, x)
+ xmax = max(xmax, x)
+ ymin = min(ymin, y)
+ ymax = max(ymax, y)
+ elif ch == '+':
+ # turtle right(angle)
+ k = (k + 1) % numAngle
+ elif ch == '-':
+ # turtle left(angle)
+ k = ((k - 1) + numAngle) % numAngle
+ print("L-System with %d segements.\n" % (len(curve.points)-1))
+ dwg.viewbox(xmin, ymin, xmax-xmin, ymax-ymin)
+ dwg.add(curve)
+ dwg.save()
+## end of http://code.activestate.com/recipes/577159/ }}}
+
+if __name__ == '__main__':
+ LSystem('lsys_hilbertspacefillingcurve.svg', formula=HilbertSpaceFillingCurve)
+ LSystem('lsys_levydragon.svg', formula=LevyDragon)
+ LSystem('lsys_levycurve.svg', formula=LevyCurve)
+ LSystem('lsys_kochsnowflake.svg', formula=KochSnowflake)
diff --git a/examples/basic_shapes.py b/examples/basic_shapes.py
new file mode 100644
index 0000000..5c8f9b2
--- /dev/null
+++ b/examples/basic_shapes.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#coding:utf-8
+# Author: mozman
+# Purpose: svg examples
+# Created: 07.11.2010
+# Copyright (C) 2010, Manfred Moitzi
+# License: MIT License
+
+try:
+ import svgwrite
+except ImportError:
+ # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
+ import sys, os
+ sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..'))
+
+import svgwrite
+from svgwrite import cm, mm
+
+def basic_shapes(name):
+ dwg = svgwrite.Drawing(filename=name, debug=True)
+ hlines = dwg.add(dwg.g(id='hlines', stroke='green'))
+ for y in range(20):
+ hlines.add(dwg.line(start=(2*cm, (2+y)*cm), end=(18*cm, (2+y)*cm), style=""))
+ vlines = dwg.add(dwg.g(id='vline', stroke='blue'))
+ for x in range(17):
+ vlines.add(dwg.line(start=((2+x)*cm, 2*cm), end=((2+x)*cm, 21*cm)))
+ shapes = dwg.add(dwg.g(id='shapes', fill='red'))
+
+ # set presentation attributes at object creation as SVG-Attributes
+ shapes.add(dwg.circle(center=(15*cm, 8*cm), r='2.5cm', stroke='blue',
+ stroke_width=3))
+
+ # override the 'fill' attribute of the parent group 'shapes'
+ shapes.add(dwg.rect(insert=(5*cm, 5*cm), size=(45*mm, 45*mm),
+ fill='blue', stroke='red', stroke_width=3))
+
+ # or set presentation attributes by helper functions of the Presentation-Mixin
+ ellipse = shapes.add(dwg.ellipse(center=(10*cm, 15*cm), r=('5cm', '10mm')))
+ ellipse.fill('green', opacity=0.5).stroke('black', width=5).dasharray([20, 20])
+ dwg.save()
+
+if __name__ == '__main__':
+ basic_shapes('basic_shapes.svg')
diff --git a/examples/checkerboard.py b/examples/checkerboard.py
new file mode 100644
index 0000000..cca925f
--- /dev/null
+++ b/examples/checkerboard.py
@@ -0,0 +1,73 @@
+#!/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: MIT License
+
+import sys
+import os
+
+try:
+ import svgwrite
+except ImportError:
+ sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..'))
+
+import svgwrite
+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 = """
+ .background { fill: lavenderblush; }
+ .line { stroke: firebrick; stroke-width: .1mm; }
+ .blacksquare { fill: indigo; }
+ .whitesquare { fill: hotpink; }
+"""
+
+def draw_board(dwg):
+ def group(classname):
+ return dwg.add(dwg.g(class_=classname))
+
+ # setup element groups
+ lines = group("line")
+ white_squares = group("whitesquare")
+ black_squares = group("blacksquare")
+
+ # draw lines
+ 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)))
+
+ # draw squares
+ 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)
+
+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))
+
+ # set background
+ dwg.add(dwg.rect(size=('100%','100%'), class_='background'))
+ draw_board(dwg)
+ dwg.save()
+
+if __name__== '__main__':
+ main()
diff --git a/examples/defs_test.py b/examples/defs_test.py
new file mode 100644
index 0000000..bd83ddd
--- /dev/null
+++ b/examples/defs_test.py
@@ -0,0 +1,78 @@
+import svgwrite
+
+PROGNAME = 'defs_test'
+STYLESHEET = PROGNAME + '.css'
+
+STYLES = """.red { fill: red; stroke=none; }
+.green { fill: green; stroke: none; }
+.blue { fill: blue; stroke: yellow; stroke-width: 5; }
+.yellow { fill: yellow; stroke: none; }
+.text { font-family: serif; fill: white; }
+"""
+
+def create_svg(name):
+ svg_size_width = 900
+ svg_size_height = 900
+ font_size = 20
+ triangle_size = 50
+ title1 = name + ': Example of creating your own colors and defs/use.'
+ dwg = svgwrite.Drawing(name, (svg_size_width, svg_size_height), debug=True)
+ # To separate structure from visual presentation, better use stylesheets
+ # inline stylesheets requires svgwrite version >= 1.0.1
+ # available at http://bitbucket.org/mozman/svgwrite
+ if svgwrite.version >= (1, 0, 1):
+ dwg.defs.add(dwg.style(STYLES))
+ else: # or use an external stylesheet
+ with open(STYLESHEET, 'w') as f:
+ f.write(STYLES)
+ dwg.add_stylesheet(STYLESHEET, 'noname')
+
+ # Background will be dark but not black so the background does not overwhelm the colors.
+ dwg.add(dwg.rect(insert=(0, 0), size=('100%', '100%'), fill='grey'))
+
+ # http://www.w3.org/TR/SVG11/struct.html#Head
+ # "sometimes it is desired to define a graphical object and prevent it from being directly
+ # rendered. it is only there to be referenced elsewhere. To do this, and to allow convenient
+ # grouping defined content, SVG provides the 'defs' element."
+
+ # 1. create template polygons
+ half_size = triangle_size / 2
+ points = [
+ (-half_size, -half_size),
+ (half_size, -half_size),
+ (0, triangle_size * 0.433013)
+ ]
+
+ # 2. create the symbol
+ symbol_without_fill = dwg.symbol(id='symbol_without_fill')
+
+ # 3. add symbols to the defs section
+ dwg.defs.add(symbol_without_fill)
+
+ # 4. important: define viewbox of the symbol!
+ symbol_without_fill.viewbox(-half_size, -half_size, triangle_size, triangle_size)
+
+ # and define how the symbol should behave on resizing by <use>
+ # default parameters for fit(horiz="center", vert="middle", scale="meet")
+ # seems not necessary
+ # symbol_without_fill.fit()
+
+ # 5. add triangles to the symbol containers
+ symbol_without_fill.add(dwg.polygon(points))
+
+ # 6. use symbols - param size is necessary - and only unset params can be overwritten
+ dwg.add(dwg.use(symbol_without_fill, insert=(200, 200), size=(triangle_size, triangle_size), class_='yellow'))
+ dwg.add(dwg.use(symbol_without_fill, insert=(300, 300), size=(triangle_size*1.2, triangle_size*1.2), class_ ='red'))
+ dwg.add(dwg.use(symbol_without_fill, insert=(400, 400), size=(triangle_size*0.5, triangle_size*0.5), class_ ='blue'))
+
+ # Give the name of the example and a title.
+ y = font_size + 5
+ dwg.add(dwg.text(title1, insert=(0, y), class_='text', font_size=font_size))
+ dwg.save()
+
+if __name__ == '__main__':
+ create_svg(PROGNAME + '.svg')
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 textwidth=99
+
+
diff --git a/examples/fePointLight.py b/examples/fePointLight.py
new file mode 100644
index 0000000..2dbbffe
--- /dev/null
+++ b/examples/fePointLight.py
@@ -0,0 +1,36 @@
+try:
+ import svgwrite
+except ImportError:
+ # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
+ import sys, os
+ sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..'))
+
+import svgwrite
+dwg = svgwrite.Drawing("fePointLight.svg")
+
+filtr = dwg.defs.add(
+ dwg.filter(id="DL", start=(0, 0), size=(500, 500),
+ filterUnits="userSpaceOnUse"))
+diffuse_lighting = filtr.feDiffuseLighting(
+ start=(0, 0), size=(500, 500),
+ surfaceScale=10,
+ diffuseConstant=1,
+ kernelUnitLength=1,
+ lighting_color="#f8f")
+point_light = diffuse_lighting.fePointLight( (500, 250, 250) )
+point_light.add(
+ dwg.animate('x',
+ values=(0,100,500,100,0),
+ dur='30s',
+ repeatDur='indefinite'))
+point_light.add(
+ dwg.animate('y',
+ values=(0,500,400,-100,0),
+ dur='31s',
+ repeatDur='indefinite'))
+point_light.add(
+ dwg.animate('z',
+ values=(0,1000,500,-100,0),
+ dur='37s',
+ repeatDur='indefinite'))
+dwg.save()
diff --git a/examples/koch_snowflake.py b/examples/koch_snowflake.py
new file mode 100644
index 0000000..401026c
--- /dev/null
+++ b/examples/koch_snowflake.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+#coding:utf-8
+# Author: mozman
+# Purpose: svg examples
+# Created: 08.09.2010
+# Copyright (C) 2010, Manfred Moitzi
+# License: MIT License
+
+try:
+ import svgwrite
+except ImportError:
+ # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
+ import sys, os
+ sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..'))
+
+import math
+import svgwrite
+
+def koch_snowflake(name):
+ # Koch Snowflake and Sierpinski Triangle combination fractal using recursion
+ # ActiveState Recipe 577156
+ # Created by FB36 on Sat, 27 Mar 2010 (MIT)
+ # http://code.activestate.com/recipes/577156-koch-snowflake-and-sierpinski-triangle-combination/
+
+ def tf (x0, y0, x1, y1, x2, y2):
+ a = math.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2)
+ b = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
+ c = math.sqrt((x0 - x2) ** 2 + (y0 - y2) ** 2)
+
+ if (a < stop_val) or (b < stop_val) or (c < stop_val):
+ return
+
+ x3 = (x0 + x1) / 2
+ y3 = (y0 + y1) / 2
+ x4 = (x1 + x2) / 2
+ y4 = (y1 + y2) / 2
+ x5 = (x2 + x0) / 2
+ y5 = (y2 + y0) / 2
+ points = [(x3, y3), (x4, y4), (x5, y5)]
+
+ # append new polygon to snowflake element
+ snowflake.add(dwg.polygon(points))
+ tf(x0, y0, x3, y3, x5, y5)
... 15061 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/svgwrite.git
More information about the Python-modules-commits
mailing list