UNKNOWN
Project description
Simple python library for programatically building SVG XML. (backed by xml4h https://github.com/jmurty/xml4h)
Why
There are two solid libraries for doing similar things already (pySVG http://codeboje.de/pysvg/ and svgwrite https://pypi.python.org/pypi/svgwrite/), but neither does quite what I find myself needing so succinctly as this.
Installation
pip install simplesvg
Functions
- A note on **kwargs
For all of the kwarg-using functions below, any arguments passed will be directly added to the XML elements. Camel case will be converted to hyphenated words automatically (e.g. strokeWidth becomes stroke-width). Common usage of this would be fill, stroke, stroke-width, and id. See example.py for some usage of these.
- simplesvg.SVG(width, height, **kwargs)
Creates a new SVG document with specified with and height (in pixels). Elements within can exceed these bounds (but they might not be rendered depending on what’s being used to display the SVG).
- SVG.to_xml()
Serializes the document to XML and returns the resulting string.
- SVG.circle(x, y, r, **kwargs)
x, y = coordinate for the center of the circle
r = radius
- SVG.rectangle(x, y, width, height, **kwargs)
x, y = coordinate of the upper-left corner of the rectangle
width, height = dimensions of the rectangle
- SVG.line(x1, y1, x2, y2, **kwargs)
x1, y1 = coordinate of the first point.
x2, y2 = coordinate of the second point.
- SVG.polygon(points, **kwargs)
points = an ordered list of pairs representing points on the polygon (e.g. [(1,2), (3,4), (1,6]])
- simplesvg.rgb(r, g, b)
Helper function that you can pass with fill or stroke to used RGB colors instead of named colors.
See example.py in the repo for usage of all of this.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file simplesvg-0.1.1.tar.gz
.
File metadata
- Download URL: simplesvg-0.1.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e530f648322a9430f98740bc326b4c01a3947198b226f9a2186fca79f1527d4 |
|
MD5 | 192bfa4d337ac29398d22df24172fadc |
|
BLAKE2b-256 | 05a3b05d51b7fa2465659e376a88f49f410c18d165280ee177c3249f360f4f9e |