Simple Inkscape Scripting v2.0.0
This is a major new release of Simple Inkscape Scripting. You'll definitely want to upgrade to pick up all the exciting new features!
Breaking API changes
The API has been made more consistent in terms of scalar versus tuple/list arguments. Items serving the same purpose are now consistently 2-tuples (for two of the same item) or lists (for varying numbers of items). For example, x and y radii are now specified as a single tuple, and lists of coordinates are now specified as a list rather than as an arbitrary number of individual arguments. These changes affect, in particular, ellipse
, polyline
, polygon
, arc
, and path
. Please update your existing Simple Inkscape Scripting scripts accordingly.
For convenience, arc
accepts a scalar radius as a shorthand for a tuple containing two of the same radii; and path
can accept a single string in addition to a list of terms, as the former may be helpful when copying and pasting from an existing SVG path string.
Other improvements
There are a lot these. Look at all the good things you get when you upgrade to Simple Inkscape Scripting v2.0.0:
-
The distribution includes an output extension that lets you save an SVG image as a Simple Inkscape Scripting script. Go to File → Save a Copy… and select
Simple Inkscape Scripting script (*.py)
from the pull-down menu. -
SVG filter effects can be defined using the new
filter
function. -
All Simple Inkscape Scripting shape objects provide a new
bounding_box
method. -
rect
can additionally draw rounded rectangles. -
Simple Inkscape Scripting objects define a Python
__str__
method that converts them to a string of the formurl(#object-id)
. This enables them to be used as style values (which are automatically converted to strings). For example, text can be flowed into a frame withshape_inside=
frame object. -
text
accepts an optionalpath
argument that typesets the text along a path. -
New
linear_gradient
andradial_gradient
functions (and the correspondingadd_stop
method) support the creation of gradient patterns, which can be used as arguments tofill
andstroke
. -
Scripts no longer need to declare their own functions as
global
in order to invoke them. -
Simple Inkscape Scripting's
print
statement has been redefined to accept multiple arguments, just like Python's built-inprint
statement. -
For advanced users, the root of the SVG XML tree is made available via an
svg_root
variable. -
Layers can be created with the new
layer
function. -
The
add
method ongroup
- andlayer
-produced objects accepts a list of objects in addition to a single object. -
All of
inkex.paths
is imported into the script's namespace. This provides convenient access to path-element constructors such asMove
,Line
, andCurve
. -
Transform
frominkex.transforms
is imported into the script's namespace. This provides a rich mechanism for manipulating object transformations.Transform
objects can be used as a shape-creation function'stransform
parameter.
Whew! More examples are included in the examples/
directory to demonstrate usage of these new features. There are also myriad improvements to the Simple Inkscape Scripting code itself, making it cleaner and more robust, but that are not visible to users.