<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.inkscape.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Matyilona</id>
	<title>Inkscape Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.inkscape.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Matyilona"/>
	<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/Special:Contributions/Matyilona"/>
	<updated>2026-05-10T00:52:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Script_extensions&amp;diff=107351</id>
		<title>Script extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Script_extensions&amp;diff=107351"/>
		<updated>2017-11-06T20:59:35Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* See Also */ Adding link to Python modules for extensions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[Note: This page concerns using scripting languages to create new Inkscape functionality.  To access Inkscape functionality from scripting languages (i.e. to script Inkscape), see the Inkscape man page (especially in the development version or v0.46 or later, which provide --select and --verb options), or see the work in the src/extension/script directory of Inkscape source.]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Traditional Unix scripts can be used to extend Inkscape's functionality. Such programs read a stream of data on standard input, transform the data in some way, and then write the modified data to standard output. This is an easy way to expand Inkscape and provide custom functionality without learning the internals of Inkscape. Libraries for reading and writing SVG data exist for many programming languages, and most provide support for XML.  This tutorial describes the &amp;quot;ins and outs&amp;quot; of writing one of these scripts and making it work with Inkscape's core functionality.&lt;br /&gt;
&lt;br /&gt;
== Script functions ==&lt;br /&gt;
&lt;br /&gt;
There are three kinds of functions that can be added with a script:&lt;br /&gt;
&lt;br /&gt;
* Input, providing translation from a file format to SVG&lt;br /&gt;
* Output, providing translation from SVG to a format&lt;br /&gt;
* Effect, taking in SVG, changing it, and then outputting SVG&lt;br /&gt;
&lt;br /&gt;
While all of these are very similar in the scripting interface, there are slight differences between them.&lt;br /&gt;
&lt;br /&gt;
== Interaction ==&lt;br /&gt;
&lt;br /&gt;
It is important for a script author to understand how Inkscape and scripts communicate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(interpreter)? your_script (--param=value)* /path/to/input[[/SVGfile]] | inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Inkscape runs your script (optionally with an interpreter, more info here: [[Extension_Interpreters | Extension Interpreters]]), passing it any number of parameters in long gnu style. The final argument is the name of the temporary svg file your script should read. After processing, the script should return the modified svg file to inkscape on STDOUT.&lt;br /&gt;
&lt;br /&gt;
== Important Tips ==&lt;br /&gt;
&lt;br /&gt;
* Receive the inkscape arguments.&lt;br /&gt;
* Clear temp files if it creates one.&lt;br /&gt;
* Write full changed SVG to the default output.&lt;br /&gt;
* Don't break an &amp;lt;code&amp;gt;xml:space=&amp;quot;preserve&amp;quot;&amp;lt;/code&amp;gt; area.&lt;br /&gt;
* Send error text to the error output and help the user.&lt;br /&gt;
&lt;br /&gt;
== Extension description file ==&lt;br /&gt;
&lt;br /&gt;
In order for Inkscape to make use of an external script or program, you must describe that script to Inkscape using an INX file. See the inkscape share directory for examples.&lt;br /&gt;
&lt;br /&gt;
The INX file allows you to:&lt;br /&gt;
* Define the script file and other dependencies.&lt;br /&gt;
* List all parameters and their types (to generate an input dialog window).&lt;br /&gt;
* Mark dialog window text for translation.&lt;br /&gt;
* Define an Inkscape menu entry.&lt;br /&gt;
* Chain extensions.&lt;br /&gt;
&lt;br /&gt;
See [[INX extension descriptor format]] for help creating an INX file.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
The INX file describes which parameters the extension needs. Inkscape will prompt the user with a UI to fill out these parameters before the extension is called. Each parameter will be passed to the script as &amp;lt;code&amp;gt;--paramname=paramvalue&amp;lt;/code&amp;gt;. Specify the script file to be run with the &amp;lt;code&amp;gt;&amp;lt;command&amp;gt;&amp;lt;/code&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
For example, if you have described a string parameter with name &amp;lt;code&amp;gt;string1&amp;lt;/code&amp;gt; in the INX file, Inkscape will present a textbox to the user. When the user fills in &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; and presses Apply, it will pass &amp;lt;code&amp;gt;--string1=&amp;quot;text&amp;quot;&amp;lt;/code&amp;gt; to the script.&lt;br /&gt;
&lt;br /&gt;
There are several types of parameters that can be requested by the INX description:&lt;br /&gt;
&lt;br /&gt;
* String (textbox)&lt;br /&gt;
* Boolean (checkbox)&lt;br /&gt;
* Int (numeric textbox)&lt;br /&gt;
* Float (numeric textbox)&lt;br /&gt;
* Enum (drop down selection list)&lt;br /&gt;
* Option group (radio buttons)&lt;br /&gt;
* Notebook (pages/tabs)&lt;br /&gt;
* Description (not a parameter, provides static text)&lt;br /&gt;
&lt;br /&gt;
For a detailed description of all parameters and input controls, see [[INX Parameters]].&lt;br /&gt;
&lt;br /&gt;
== Verbs interface and the id tag ==&lt;br /&gt;
When you define your extension you will have name and id tags at the top of the INX file.&lt;br /&gt;
The id tag is used for two purposes:&lt;br /&gt;
&lt;br /&gt;
* as an identifier in the config file so the most recently used parameter values are stored and recalled each time the extension is run.&lt;br /&gt;
* as the identifier for the verbs interface so your extension can be run from the command line.&lt;br /&gt;
&lt;br /&gt;
Inkscape can be called from the command line and the extension can be run using this interface.&lt;br /&gt;
&lt;br /&gt;
E.g. Assuming the id in your extension was &amp;lt;code&amp;gt;&amp;lt;id&amp;gt;foo.github.my_extension&amp;lt;/id&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;inkscape --verb foo.github.my_extension&amp;lt;/code&amp;gt; will open Inkscape and open the dialog to your extension..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;inkscape --verb foo.github.my_extension.noprefs&amp;lt;/code&amp;gt; will open inkscape and run the dialog with the last set values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;inkscape --verb ZoomPage --verb foo.github.my_extension&amp;lt;/code&amp;gt; will open inkscape, Zoom full page, and open the dialog to your extension.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;inkscape --verb-list&amp;lt;/code&amp;gt;  will show you the available verbs.&lt;br /&gt;
&lt;br /&gt;
== Installing ==&lt;br /&gt;
&lt;br /&gt;
Installing is as simple as copying the script (unless it resides in your path) and its INX file to the inkscape/share/extensions ($HOME/.config/inkscape/extensions) directory. (If you install a script in your home directory be sure to copy the dependencies.)&lt;br /&gt;
&lt;br /&gt;
If you are looking to use scripts that have already been written, the most difficult part will likely be the installation. Since scripts are  separate programs they may have any number of dependencies that are not included with inkscape. Currently, the best way to find missing dependencies is by reading the error messages produced by running the script from the command line.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
*[[Generating_objects_from_extensions]]. How to use a script to generate actual objects inside SVG documents.&lt;br /&gt;
&lt;br /&gt;
*[[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
*[[Python modules for extensions]]&lt;br /&gt;
&lt;br /&gt;
*[[Tips For Python Script Extensions]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer Documentation]]&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Generating_objects_from_extensions&amp;diff=107346</id>
		<title>Generating objects from extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Generating_objects_from_extensions&amp;diff=107346"/>
		<updated>2017-11-06T20:56:52Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: Adding link to Python modules for extensions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you need an extension to generate an object in Inkscape, there are many tools that already exist to help you. &amp;lt;tt&amp;gt;inkex.py&amp;lt;/tt&amp;gt; is the most notable, as this provides the routines to insert the SVG element into the XML tree of the SVG document, for more info on these is available at [[Python modules for extensions]].&lt;br /&gt;
&lt;br /&gt;
There is currently no universal set of tools to allow a single function to be called, because different extension have different attibutes for thir objects. For example, the barcode extension merely needs a black rectangle with no stroke, but another may need a way to set the stroke width, dashes and opacity. Thus, it is often best to write your own subroutine for generating your objects.&lt;br /&gt;
&lt;br /&gt;
==A simple example==&lt;br /&gt;
Let's look at a simple Python function for drawing a black rectangle:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#SVG element generation routine&lt;br /&gt;
def draw_SVG_square((w,h), (x,y), parent):&lt;br /&gt;
&lt;br /&gt;
    style = {   'stroke'        : 'none',&lt;br /&gt;
                'stroke-width'  : '1',&lt;br /&gt;
                'fill'          : '#000000'&lt;br /&gt;
            }&lt;br /&gt;
                &lt;br /&gt;
    attribs = {&lt;br /&gt;
        'style'     : simplestyle.formatStyle(style),&lt;br /&gt;
        'height'    : str(h),&lt;br /&gt;
        'width'     : str(w),&lt;br /&gt;
        'x'         : str(x),&lt;br /&gt;
        'y'         : str(y)&lt;br /&gt;
            }&lt;br /&gt;
    circ = inkex.etree.SubElement(parent, inkex.addNS('rect','svg'), attribs )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice is that all the attributes of the object are stored in a dictionary format, with everything being a string. This means you have to convert all your parameters to strings if appropriate (like the &amp;lt;tt&amp;gt;height&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;width&amp;lt;/tt&amp;gt; attributes).&lt;br /&gt;
&lt;br /&gt;
Next, all the style attributes (colours, widths, fonts, etc) are put together in SVG under &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt;. To generate this string, there exists a helper function &amp;lt;tt&amp;gt;simplestyle.formatStyle()&amp;lt;/tt&amp;gt;. You simply feed this function a dictionary of the styles you want, just like the attributes. You can then use this directly as the style attribute.&lt;br /&gt;
&lt;br /&gt;
The next thing to see is how to add the element to the XML tree. &amp;lt;tt&amp;gt;inkex.py&amp;lt;/tt&amp;gt; has the function to do this using the LXML parser. This needs to be given the &amp;quot;parent&amp;quot; of the object (we'll come back to this), the &amp;quot;type&amp;quot; of the object, and the attributes of the object.&lt;br /&gt;
&lt;br /&gt;
The type of the object is in the &amp;lt;tt&amp;gt;svg&amp;lt;/tt&amp;gt; namespace, which means it begins &amp;lt;tt&amp;gt;svg:&amp;lt;/tt&amp;gt; (for a rectangle, it is &amp;lt;tt&amp;gt;svg:rect&amp;lt;/tt&amp;gt;). LXML cannot parse colons, so we use the &amp;lt;tt&amp;gt;inkex.addNS&amp;lt;/tt&amp;gt; to prepend the namespace.&lt;br /&gt;
&lt;br /&gt;
The attributes of the object just needs to be passed the dictionary &amp;lt;tt&amp;gt;attribs&amp;lt;/tt&amp;gt; we made earlier.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;parent&amp;quot; of the object is the containing element. This is usually a group or a layer. This will be passed in by the calling function, and we will see it in action later.&lt;br /&gt;
&lt;br /&gt;
When this function is run with the right parameters, the rectangle will be added to the SVG document.&lt;br /&gt;
&lt;br /&gt;
==Getting the parent==&lt;br /&gt;
&lt;br /&gt;
Finding the parent is easy: you can just pass in the current layer from the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; object if you like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
parent = self.current_layer&lt;br /&gt;
draw_SVG_square((1,1), (0,0), parent)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will just plonk the rectangle into the document, centred on the origin.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can create a group much like any other object:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
centre = self.view_center   #Put in in the centre of the current view&lt;br /&gt;
grp_transform = 'translate' + str( centre )&lt;br /&gt;
&lt;br /&gt;
grp_name = 'Group Name'&lt;br /&gt;
grp_attribs = {inkex.addNS('label','inkscape'):grp_name,&lt;br /&gt;
                           'transform':grp_transform }&lt;br /&gt;
grp = inkex.etree.SubElement(self.current_layer, 'g', grp_attribs)#the group to put everything in&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By the way, any object can be assigned a name as we did there, which is often helpful when generating many objects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
inkex.addNS('label','inkscape') : name&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting the transform as &amp;lt;tt&amp;gt;self.view_center&amp;lt;/tt&amp;gt;, we made sure the origin of the group is in the centre of the current view of the document. We will come back to transforms later.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;grp&amp;lt;/tt&amp;gt; object can now be used as a parent for the rectangle:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
draw_SVG_square((1,1), (0,0), grp)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will draw a 1×1 black square in the center of the view.&lt;br /&gt;
&lt;br /&gt;
==Transforms==&lt;br /&gt;
&lt;br /&gt;
It is easy to transform an object: just supply a string like the folllowing as the &amp;lt;tt&amp;gt;transform&amp;lt;/tt&amp;gt; attribute of the element:&lt;br /&gt;
*&amp;lt;tt&amp;gt;trans = 'translate(10,10)'&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;trans = 'translate(10,10) rotate(10)'&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;trans = 'skewX(-1)'&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. The transforms are composed in left-right order (i.e. the translate comes first in the second example).&lt;br /&gt;
&lt;br /&gt;
==More Examples==&lt;br /&gt;
&lt;br /&gt;
===Ellipses===&lt;br /&gt;
&lt;br /&gt;
Ellipses are actually path elements, but Inkscape generates the nodes automatically if you feed it the correct attributes in the Sodipodi namespace. The vital ones are &amp;lt;tt&amp;gt;rx, ry, cx, cy&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Ellipses require some attributes in the &amp;lt;tt&amp;gt;sodipodi:&amp;lt;/tt&amp;gt; namespace, so we also use the &amp;lt;tt&amp;gt;addNS()&amp;lt;/tt&amp;gt; function in the attribute dictionary:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
def draw_SVG_ellipse((rx, ry), (cx, cy), parent, start_end=0,2*pi),transform='' ):&lt;br /&gt;
&lt;br /&gt;
    style = {   'stroke'        : '#000000',&lt;br /&gt;
                'stroke-width'  : '1',&lt;br /&gt;
                'fill'          : 'none'            }&lt;br /&gt;
    ell_attribs = {'style':simplestyle.formatStyle(style),&lt;br /&gt;
        inkex.addNS('cx','sodipodi')        :str(cx),&lt;br /&gt;
        inkex.addNS('cy','sodipodi')        :str(cy),&lt;br /&gt;
        inkex.addNS('rx','sodipodi')        :str(rx),&lt;br /&gt;
        inkex.addNS('ry','sodipodi')        :str(ry),&lt;br /&gt;
        inkex.addNS('start','sodipodi')     :str(start_end[0]),&lt;br /&gt;
        inkex.addNS('end','sodipodi')       :str(start_end[1]),&lt;br /&gt;
        inkex.addNS('open','sodipodi')      :'true',    #all ellipse sectors we will draw are open&lt;br /&gt;
        inkex.addNS('type','sodipodi')      :'arc',&lt;br /&gt;
        'transform'                         :transform&lt;br /&gt;
        &lt;br /&gt;
            }&lt;br /&gt;
    ell = inkex.etree.SubElement(parent, inkex.addNS('path','svg'), ell_attribs )&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will draw an open arc, with a black stroke of width 1 and no fill. The transform here can be passed in from outside.&lt;br /&gt;
&lt;br /&gt;
If in doubt about the right attribute name and format, just check a similar object in the XML viewer in Inkscape.&lt;br /&gt;
&lt;br /&gt;
===Line Segment===&lt;br /&gt;
&lt;br /&gt;
Paths can be quite tricky to get the hang of if you don't know the meaning of the letters. Read the SVG specification for a full list.&lt;br /&gt;
&lt;br /&gt;
Here, the style information has been passed in from outside the function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#draw an SVG line segment between the given (raw) points&lt;br /&gt;
def draw_SVG_line( (x1, y1), (x2, y2), style, name, parent):&lt;br /&gt;
    line_style   = { 'stroke': style.l_col,&lt;br /&gt;
                     'stroke-width':str(style.l_th),&lt;br /&gt;
                     'fill': style.l_fill&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
    line_attribs = {'style' : simplestyle.formatStyle(line_style),&lt;br /&gt;
                    inkex.addNS('label','inkscape') : name,&lt;br /&gt;
                    'd' : 'M '+str(x1)+','+str(y1)+' L '+str(x2)+','+str(y2)}&lt;br /&gt;
&lt;br /&gt;
    line = inkex.etree.SubElement(parent, inkex.addNS('path','svg'), line_attribs )&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer Documentation]]&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=PythonEffectTutorial&amp;diff=107341</id>
		<title>PythonEffectTutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=PythonEffectTutorial&amp;diff=107341"/>
		<updated>2017-11-06T20:53:06Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* Effect Extension Script */ provide link to documentation of inkex.py and simplestyle.py&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Effect extensions in Inkscape means a simple programs or scripts that reads an SVG file from standard input, transforms it somehow and prints it to the standard output. Usually Inkscape sits on both ends, providing the file with some parameters as input first and finally reading the output, which is then used for further work.&lt;br /&gt;
[[Image:Effect_flow.svg|thumb|right|400px]]&lt;br /&gt;
&lt;br /&gt;
We will write a simple effect extension script in [http://docs.python.org Python] that will create a new &amp;quot;Hello World!&amp;quot; or &amp;quot;Hello &amp;lt;value of --what option&amp;gt;!&amp;quot; string in the center of document and inside a new layer.&lt;br /&gt;
&lt;br /&gt;
== Effect Extension Script ==&lt;br /&gt;
&lt;br /&gt;
First of all create a file ''hello_world.py'' and make it executable with the Python interpreter with the well-known directive:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're going to put the file somewhere else than into Inkscape's installation directory, we need to add a path so that python can find the necessary modules:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Import the ''inkex.py'' file with the ''Effect'' base class that will do most of the work for us and the ''simplestyle.py'' module with support functions for working with CSS styles, for more information on these modules see [[Python modules for extensions]]. We will use just the ''formatStyle'' function from this module:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import inkex&lt;br /&gt;
from simplestyle import *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Declare a ''HelloWordEffect'' class that inherits from ''Effect'' and write a constructor where the base class is initialized and script options for the option parser are defined:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class HelloWorldEffect(inkex.Effect):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        inkex.Effect.__init__(self)&lt;br /&gt;
        self.OptionParser.add_option('-w', '--what', action = 'store',&lt;br /&gt;
          type = 'string', dest = 'what', default = 'World',&lt;br /&gt;
          help = 'What would you like to greet?')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The complete documentation for the ''OptionParser'' class can be found at [https://docs.python.org/2/library/optparse.html docs.python.org]. Here we just use the ''add_option'' method which has as first argument a short option name, as second argument a long option name and then a few other arguments with this meaning:&lt;br /&gt;
&lt;br /&gt;
* ''action'' - An action which should be done with option value. In this case we use action ''store'' which will store option value in ''self.options.&amp;lt;destination&amp;gt;'' attribute.&lt;br /&gt;
* ''type'' - Type of option value. We use string here.&lt;br /&gt;
* ''dest'' - Destination of option action specified by ''action'' argument. Using ''what'' value we say that we want to store option value to self.options.what attribute.&lt;br /&gt;
* ''default'' - Defalut value for this option if it is not specified.&lt;br /&gt;
* ''help'' - A help string that will be displayed if script will be given no arguments or some option or argument will have wrong syntax.&lt;br /&gt;
&lt;br /&gt;
Inkscape will create a GUI form with widgets for all specified options and prefill them with the default values specified using the ''.inx'' file for this extension which we will write later. &lt;br /&gt;
&lt;br /&gt;
We need to override only one ''Effect'' class method to provide the desired effect functionality: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def effect(self):&lt;br /&gt;
        what = self.options.what&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can imagine we just stored the ''--what'' option value to the ''what'' variable.&lt;br /&gt;
&lt;br /&gt;
Now we will finally start to do something. We will have to work with the XML representation of the SVG document that we can access via ''Effect'''s ''self.document'' attribute.&lt;br /&gt;
It is of lxml's '' _ElementTree'' class type.  Complete documentation for the lxml package can be found at [http://lxml.de/ lxml.de].&lt;br /&gt;
&lt;br /&gt;
First we get SVG document's ''svg'' element and its dimensions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        svg = self.document.getroot()&lt;br /&gt;
        # or alternatively&lt;br /&gt;
        # svg = self.document.xpath('//svg:svg',namespaces=inkex.NSS)[0]&lt;br /&gt;
&lt;br /&gt;
        # Again, there are two ways to get the attibutes:&lt;br /&gt;
        width  = self.unittouu(svg.get('width'))&lt;br /&gt;
        height = self.unittouu(svg.attrib['height'])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The ''xpath'' function returns a list of all matching elements so we just use the first one of them.&lt;br /&gt;
&lt;br /&gt;
We now create an SVG group element ('' 'g' '') and &amp;quot;mark&amp;quot; it as a layer using Inkscape' SVG extensions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        layer = inkex.etree.SubElement(svg, 'g')&lt;br /&gt;
        layer.set(inkex.addNS('label', 'inkscape'), 'Hello %s Layer' % (what))&lt;br /&gt;
        layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates ''inkscape:label'' and ''inkscape:groupmode'' attributes, which will only be read by Inkscape or compatible applications.  To all other viewers, this new element looks just like a plain SVG group.&lt;br /&gt;
&lt;br /&gt;
Now we create an SVG text element with a text value containing the &amp;quot;Hello World&amp;quot; string:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        text = inkex.etree.Element(inkex.addNS('text','svg'))&lt;br /&gt;
        text.text = 'Hello %s!' % (what)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the position of the text to the center of SVG document:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        text.set('x', str(width / 2))&lt;br /&gt;
        text.set('y', str(height / 2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we want to center the text on its position we need to define the CSS style of the SVG ''text'' element. Actually we use the ''text-anchor'' SVG extension to CSS styles to do that work:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        style = {'text-align' : 'center', 'text-anchor' : 'middle'}&lt;br /&gt;
        text.set('style', formatStyle(style))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we connect all created elements together and put them into the SVG document:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        layer.append(text)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We just defined a class that inherited from the original effect extension so we have to create an instance of it and execute it in the main control flow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
effect = HelloWorldEffect()&lt;br /&gt;
effect.affect()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extension Description File ==&lt;br /&gt;
&lt;br /&gt;
To include script in Inkscape's main menu create ''hello_world.inx'' file describing script evokation. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;inkscape-extension xmlns=&amp;quot;http://www.inkscape.org/namespace/inkscape/extension&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;_name&amp;gt;Hello World!&amp;lt;/_name&amp;gt;&lt;br /&gt;
  &amp;lt;id&amp;gt;org.ekips.filter.hello_world&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;dependency type=&amp;quot;executable&amp;quot; location=&amp;quot;extensions&amp;quot;&amp;gt;hello_world.py&amp;lt;/dependency&amp;gt;&lt;br /&gt;
  &amp;lt;dependency type=&amp;quot;executable&amp;quot; location=&amp;quot;extensions&amp;quot;&amp;gt;inkex.py&amp;lt;/dependency&amp;gt;&lt;br /&gt;
  &amp;lt;param name=&amp;quot;what&amp;quot; type=&amp;quot;string&amp;quot; _gui-text=&amp;quot;What would you like to greet?&amp;quot;&amp;gt;World&amp;lt;/param&amp;gt;&lt;br /&gt;
  &amp;lt;effect&amp;gt;&lt;br /&gt;
    &amp;lt;object-type&amp;gt;all&amp;lt;/object-type&amp;gt;&lt;br /&gt;
    &amp;lt;effects-menu&amp;gt;&lt;br /&gt;
       &amp;lt;submenu _name=&amp;quot;Examples&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/effects-menu&amp;gt;&lt;br /&gt;
  &amp;lt;/effect&amp;gt;&lt;br /&gt;
  &amp;lt;script&amp;gt;&lt;br /&gt;
    &amp;lt;command reldir=&amp;quot;extensions&amp;quot; interpreter=&amp;quot;python&amp;quot;&amp;gt;hello_world.py&amp;lt;/command&amp;gt;&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/inkscape-extension&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ''&amp;lt;param&amp;gt;'' element for every option of a script and ''&amp;lt;dependency&amp;gt;'' for every included module which is not from Python standard library. Inkscape will search for this modules in directory with script. ''&amp;lt;effect&amp;gt;'' element and its descendants defines name of menu item evoking our new &amp;quot;Hello World!&amp;quot; extension.&lt;br /&gt;
&lt;br /&gt;
If the inx file isn't well formed or if any of the dependencies wasn't met, the extension won't show up in the menu. If your extension doesn't show up, take a look at extension-errors.log, which may give you a hint why it wasn't loaded.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
To install a new extenstion just put ''hello_world.py'' and ''hello_world.inx'' files with all dependency modules to the ''&amp;lt;path_to_inkscape&amp;gt;/extensions'' or ''~/.config/inkscape/extensions'' directory.  On Linux you will probably have to make the python script executable first if you haven't done this yet.  This is usually done by the usual command (or in your preferred file manager):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ chmod a+x hello_world.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now start Inkscape. A new menu item ''Hello World!'' in ''Extensions-&amp;gt;Examples'' menu should appear.&lt;br /&gt;
&lt;br /&gt;
== Complete Source Code ==&lt;br /&gt;
&lt;br /&gt;
Here is a complete commented source pre of ''hello_world.py'' script file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# These two lines are only needed if you don't put the script directly into&lt;br /&gt;
# the installation directory&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append('/usr/share/inkscape/extensions')&lt;br /&gt;
&lt;br /&gt;
# We will use the inkex module with the predefined Effect base class.&lt;br /&gt;
import inkex&lt;br /&gt;
# The simplestyle module provides functions for style parsing.&lt;br /&gt;
from simplestyle import *&lt;br /&gt;
&lt;br /&gt;
class HelloWorldEffect(inkex.Effect):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Example Inkscape effect extension.&lt;br /&gt;
    Creates a new layer with a &amp;quot;Hello World!&amp;quot; text centered in the middle of the document.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Constructor.&lt;br /&gt;
        Defines the &amp;quot;--what&amp;quot; option of a script.&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        # Call the base class constructor.&lt;br /&gt;
        inkex.Effect.__init__(self)&lt;br /&gt;
&lt;br /&gt;
        # Define string option &amp;quot;--what&amp;quot; with &amp;quot;-w&amp;quot; shortcut and default value &amp;quot;World&amp;quot;.&lt;br /&gt;
        self.OptionParser.add_option('-w', '--what', action = 'store',&lt;br /&gt;
          type = 'string', dest = 'what', default = 'World',&lt;br /&gt;
          help = 'What would you like to greet?')&lt;br /&gt;
&lt;br /&gt;
    def effect(self):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Effect behaviour.&lt;br /&gt;
        Overrides base class' method and inserts &amp;quot;Hello World&amp;quot; text into SVG document.&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        # Get script's &amp;quot;--what&amp;quot; option value.&lt;br /&gt;
        what = self.options.what&lt;br /&gt;
&lt;br /&gt;
        # Get access to main SVG document element and get its dimensions.&lt;br /&gt;
        svg = self.document.getroot()&lt;br /&gt;
        # or alternatively&lt;br /&gt;
        # svg = self.document.xpath('//svg:svg',namespaces=inkex.NSS)[0]&lt;br /&gt;
&lt;br /&gt;
        # Again, there are two ways to get the attibutes:&lt;br /&gt;
        width  = self.unittouu(svg.get('width'))&lt;br /&gt;
        height = self.unittouu(svg.attrib['height'])&lt;br /&gt;
&lt;br /&gt;
        # Create a new layer.&lt;br /&gt;
        layer = inkex.etree.SubElement(svg, 'g')&lt;br /&gt;
        layer.set(inkex.addNS('label', 'inkscape'), 'Hello %s Layer' % (what))&lt;br /&gt;
        layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')&lt;br /&gt;
&lt;br /&gt;
        # Create text element&lt;br /&gt;
        text = inkex.etree.Element(inkex.addNS('text','svg'))&lt;br /&gt;
        text.text = 'Hello %s!' % (what)&lt;br /&gt;
&lt;br /&gt;
        # Set text position to center of document.&lt;br /&gt;
        text.set('x', str(width / 2))&lt;br /&gt;
        text.set('y', str(height / 2))&lt;br /&gt;
&lt;br /&gt;
        # Center text horizontally with CSS style.&lt;br /&gt;
        style = {'text-align' : 'center', 'text-anchor': 'middle'}&lt;br /&gt;
        text.set('style', formatStyle(style))&lt;br /&gt;
&lt;br /&gt;
        # Connect elements together.&lt;br /&gt;
        layer.append(text)&lt;br /&gt;
&lt;br /&gt;
# Create effect instance and apply it.&lt;br /&gt;
effect = HelloWorldEffect()&lt;br /&gt;
effect.affect()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Last edited by --[[User:Rubikcube|Rubikcube]] 21:18, 7 August 2008 (UTC), based on a version by&lt;br /&gt;
[[User:Blackhex|Blackhex]] 11:59, 26 April 2007 (UTC)&lt;br /&gt;
[[Category:Developer Documentation]]&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107291</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107291"/>
		<updated>2017-11-04T21:55:35Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* simpletransform.py */ Detailed description for simpletransform&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicking that datastructure, and additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse SVG path and return an array of segments. Removes all shorthand notation. Converts coordinates to absolute. Returns list of &amp;lt;code&amp;gt;[ command, params ]&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( l )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path data from a list. Returns the string representing the path, &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; should have the same format as returned by &amp;lt;code&amp;gt;parsePath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;translatePath( p, x, y ), scalePath( p, x, y ), rotatePath( p, angle, cx=0, cy=0 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Transforms path &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation, accessing both handles of a node at once. Loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;CubicSuperPath( simplepath )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path as a list returned by &amp;lt;code&amp;gt;simplepath.parsePath&amp;lt;/code&amp;gt;, it returns a list of lists in &amp;lt;code&amp;gt;[ [ [ h1_0, pt_0, h2_0 ], [ h1_1, pt_1, h2_1 ], ... ], [ [ h1_m, pt_m, h2_m ], ...], ... ]&amp;lt;/code&amp;gt; format, where &amp;lt;code&amp;gt;h1_n&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;h2_n&amp;lt;/code&amp;gt; are handles for the node at point &amp;lt;code&amp;gt;pt_n&amp;lt;/code&amp;gt;. All points/handles are lists of two floats (&amp;lt;code&amp;gt;[ x, y ]&amp;lt;/code&amp;gt;). The list is the representation of the whole path, the first level sub-lists are representations of sub-paths, and the lists containing 3 points represent the individual control nodes. &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;unCubicSuperPath( csp )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path in the format returned by &amp;lt;code&amp;gt;CubicSuperPath&amp;lt;/code&amp;gt; returns it in the format used by &amp;lt;code&amp;gt;simplepath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse a string representation directly.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( p )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path as a string.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects. Transformations are represented as [https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations affine transformation matrices]. Since the last row of such matrices is always the same ([0,0,1]) it is not included, so the final matrix is a list of two lists of 3 floats containing the first two rows of the matrix. Wherever &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; is used as a default argument it means the identity matrix, a transformation that does nothing.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseTransform( transform, mat=E )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Takes a string representing a transformation (like a SVG nodes transform attribute), and returns a transformation matrix. If &amp;lt;code&amp;gt;mat&amp;lt;/code&amp;gt; is supplied, the returned matrix is &amp;lt;code&amp;gt;composeTransform( mat, matrix)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatTransform( mat )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns string representation for transform (for use in transform attribute).&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;invertTransform( mat )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns inverse of transformation given by &amp;lt;code&amp;gt;mat&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;composeTransform( mat1, mat2 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns matrix representing a transformation equal to applying &amp;lt;code&amp;gt;mat1&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;mat2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;composeParents( node, mat )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns &amp;lt;code&amp;gt;mat&amp;lt;/code&amp;gt; composed with every transformation that applies to &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. If a node has a transformation applied to it, and is part of a group that has an other transformation applied to it, both apply to the node. This function composes all the nodes ancestors' transformations.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;applyTransformToNode( mat, node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Apply transform to &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt; by setting its transform attribute, does not change coordinates in any part of node.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;applyTransformToPath( mat, path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Apply transform to path, by changing the coordinates of points and handles. &amp;lt;code&amp;gt;path&amp;lt;/code&amp;gt; has to be a representation used by &amp;lt;code&amp;gt;SuperCubicPath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;applyTransformToPoint( mat, point )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Apply transform to a point given as a list &amp;lt;code&amp;gt;[ x, y ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;fuseTransform( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Removes the transform attribute from a node, and applies it to the node, changing the nodes points' coordinates.&lt;br /&gt;
&lt;br /&gt;
The following functions might be broken out into a separate module in the future (see comment in code).&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;roughBBox( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns four floats &amp;lt;code&amp;gt;xmin, xMax, ymin, yMax&amp;lt;/code&amp;gt;, the coordinates for a rough bounding box. &amp;lt;code&amp;gt;path&amp;lt;/code&amp;gt; has to be a representation used by &amp;lt;code&amp;gt;SuperCubicPath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;refinedBBox( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Same as the above, takes longer to calculate but more precise.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;computeBBox( node_list, mat = E )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the bounding box for a list of nodes. If supplied &amp;lt;code&amp;gt;mat&amp;lt;/code&amp;gt; is applied to the nodes before calculating the bounding box. Uses &amp;lt;code&amp;gt;refinedBBox&amp;lt;/code&amp;gt; when applicable, text nodes are not yet supported.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;computePointInNode( pt, node, mat = E )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a point and a node, returns the coordinates that when transformed by the nodes and its ancestors transformations are the same as &amp;lt;code&amp;gt;pt&amp;lt;/code&amp;gt;. For example take a circle created with its centre at (0,0) and then transformed by applying a pure translation to (1,0). If the centre is now set to (0,1) the centre of the circle will actually be at (1,1) because the transformation still applies. It can be avoided by using &amp;lt;code&amp;gt;computePointInNode( [ 0, 1 ], circle )&amp;lt;/code&amp;gt; which gives (-1,1), setting the centre to this the circle will appear at the desired (0,1).&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107286</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107286"/>
		<updated>2017-11-04T19:20:00Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* cubicsuperpath.py */ typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicking that datastructure, and additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse SVG path and return an array of segments. Removes all shorthand notation. Converts coordinates to absolute. Returns list of &amp;lt;code&amp;gt;[ command, params ]&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( l )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path data from a list. Returns the string representing the path, &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; should have the same format as returned by &amp;lt;code&amp;gt;parsePath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;translatePath( p, x, y ), scalePath( p, x, y ), rotatePath( p, angle, cx=0, cy=0 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Transforms path &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation, accessing both handles of a node at once. Loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;CubicSuperPath( simplepath )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path as a list returned by &amp;lt;code&amp;gt;simplepath.parsePath&amp;lt;/code&amp;gt;, it returns a list of lists in &amp;lt;code&amp;gt;[ [ [ h1_0, pt_0, h2_0 ], [ h1_1, pt_1, h2_1 ], ... ], [ [ h1_m, pt_m, h2_m ], ...], ... ]&amp;lt;/code&amp;gt; format, where &amp;lt;code&amp;gt;h1_n&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;h2_n&amp;lt;/code&amp;gt; are handles for the node at point &amp;lt;code&amp;gt;pt_n&amp;lt;/code&amp;gt;. All points/handles are lists of two floats (&amp;lt;code&amp;gt;[ x, y ]&amp;lt;/code&amp;gt;). The list is the representation of the whole path, the first level sub-lists are representations of sub-paths, and the lists containing 3 points represent the individual control nodes. &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;unCubicSuperPath( csp )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path in the format returned by &amp;lt;code&amp;gt;CubicSuperPath&amp;lt;/code&amp;gt; returns it in the format used by &amp;lt;code&amp;gt;simplepath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse a string representation directly.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( p )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path as a string.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects. Transformations are represented as [https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations affine transformation matrices]. Since the last row of such matrices is always the same ([0,0,1]) it is not included, so the final matrix is a list of two lists of 3 floats containing the first two rows of the matrix.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107281</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107281"/>
		<updated>2017-11-04T19:18:35Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* cubicsuperpath.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicking that datastructure, and additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse SVG path and return an array of segments. Removes all shorthand notation. Converts coordinates to absolute. Returns list of &amp;lt;code&amp;gt;[ command, params ]&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( l )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path data from a list. Returns the string representing the path, &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; should have the same format as returned by &amp;lt;code&amp;gt;parsePath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;translatePath( p, x, y ), scalePath( p, x, y ), rotatePath( p, angle, cx=0, cy=0 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Transforms path &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation, accessing both handles of a node at once. Loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;CubicSuperPath( simplepath )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path as a list returned by &amp;lt;code&amp;gt;simplepath.parsePath&amp;lt;/code&amp;gt;, it returns a list of lists in &amp;lt;code&amp;gt;[ [ [ h1_0, pt_0, h2_0 ], [ h1_1, pt_1, h2_1 ], ... ], [ [ h1_m, pt_m, h2_m ], ...], ... ]&amp;lt;/code&amp;gt; format, where &amp;lt;code&amp;gt;h1_n&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;h2_n&amp;lt;/code&amp;gt; are handles for the node at point &amp;lt;code&amp;gt;pt_n&amp;lt;/code&amp;gt;. All points/handles are lists of two floats (&amp;lt;code&amp;gt;[ x, y ]&amp;lt;/code&amp;gt;). The list is the representation of the whole path, the first level sub-lists are representations of sub-paths, and the list containing 3 points represent the individual control nodes. &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;unCubicSuperPath( csp )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path in the format returned by &amp;lt;code&amp;gt;CubicSuperPath&amp;lt;/code&amp;gt; returns it in the format used by &amp;lt;code&amp;gt;simplepath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse a string representation directly.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( p )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path as a string.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects. Transformations are represented as [https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations affine transformation matrices]. Since the last row of such matrices is always the same ([0,0,1]) it is not included, so the final matrix is a list of two lists of 3 floats containing the first two rows of the matrix.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107276</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107276"/>
		<updated>2017-11-04T19:13:43Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* simpletransform.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicking that datastructure, and additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse SVG path and return an array of segments. Removes all shorthand notation. Converts coordinates to absolute. Returns list of &amp;lt;code&amp;gt;[ command, params ]&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( l )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path data from a list. Returns the string representing the path, &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; should have the same format as returned by &amp;lt;code&amp;gt;parsePath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;translatePath( p, x, y ), scalePath( p, x, y ), rotatePath( p, angle, cx=0, cy=0 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Transforms path &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation, accessing both handles of a node at once. Loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;CubicSuperPath( simplepath )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path as a list returned by &amp;lt;code&amp;gt;simplepath.parsePath&amp;lt;/code&amp;gt;, it returns a list of lists in &amp;lt;code&amp;gt;[ [ h1_0, pt_0, h2_0 ], [ h1_1, pt_1, h2_1 ], ... ]&amp;lt;/code&amp;gt; format, where &amp;lt;code&amp;gt;h1_n&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;h2_n&amp;lt;/code&amp;gt; are handles for the node at point &amp;lt;code&amp;gt;pt_n&amp;lt;/code&amp;gt;. All points/handles are lists of two floats (&amp;lt;code&amp;gt;[ x, y ]&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;unCubicSuperPath( csp )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path in the format returned by &amp;lt;code&amp;gt;CubicSuperPath&amp;lt;/code&amp;gt; returns it in the format used by &amp;lt;code&amp;gt;simplepath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse a string representation directly.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( p )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path as a string.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects. Transformations are represented as [https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations affine transformation matrices]. Since the last row of such matrices is always the same ([0,0,1]) it is not included, so the final matrix is a list of two lists of 3 floats containing the first two rows of the matrix.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107271</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107271"/>
		<updated>2017-11-04T18:42:21Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* cubicsuperpath.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicking that datastructure, and additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse SVG path and return an array of segments. Removes all shorthand notation. Converts coordinates to absolute. Returns list of &amp;lt;code&amp;gt;[ command, params ]&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( l )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path data from a list. Returns the string representing the path, &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; should have the same format as returned by &amp;lt;code&amp;gt;parsePath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;translatePath( p, x, y ), scalePath( p, x, y ), rotatePath( p, angle, cx=0, cy=0 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Transforms path &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation, accessing both handles of a node at once. Loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;CubicSuperPath( simplepath )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path as a list returned by &amp;lt;code&amp;gt;simplepath.parsePath&amp;lt;/code&amp;gt;, it returns a list of lists in &amp;lt;code&amp;gt;[ [ h1_0, pt_0, h2_0 ], [ h1_1, pt_1, h2_1 ], ... ]&amp;lt;/code&amp;gt; format, where &amp;lt;code&amp;gt;h1_n&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;h2_n&amp;lt;/code&amp;gt; are handles for the node at point &amp;lt;code&amp;gt;pt_n&amp;lt;/code&amp;gt;. All points/handles are lists of two floats (&amp;lt;code&amp;gt;[ x, y ]&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;unCubicSuperPath( csp )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Given a path in the format returned by &amp;lt;code&amp;gt;CubicSuperPath&amp;lt;/code&amp;gt; returns it in the format used by &amp;lt;code&amp;gt;simplepath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse a string representation directly.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( p )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path as a string.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107241</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107241"/>
		<updated>2017-11-02T19:46:49Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* simplepath.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicing that datastructure, and additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parsePath( d )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Parse SVG path and return an array of segments. Removes all shorthand notation. Converts coordinates to absolute. Returns list of &amp;lt;code&amp;gt;[ command, params ]&amp;lt;/code&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;formatPath( l )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format path data from a list. Returns the string representing the path, &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; should have the same format as returned by &amp;lt;code&amp;gt;parsePath&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;transalePath( p, x, y ), scalePath( p, x, y ), rotatePath( p, angle, cx=0, cy=0 )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Transforms path &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation. access both handles of a node at once. loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107221</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107221"/>
		<updated>2017-11-01T15:49:47Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: /* simplestyle.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; is a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicing that datastructure. additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation. access both handles of a node at once. loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107216</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107216"/>
		<updated>2017-11-01T15:45:58Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: Reformatting and extending simplestyle.py&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embedded in SVG's style attribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary of attribute-value pairs from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary of attribute-value pairs, values are converted to strings by &amp;lt;code&amp;gt;str()&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if its a valid color.&lt;br /&gt;
;&amp;lt;code&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array. &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; can be any type of string representation of a color.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert 3 floats to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;svgcolors&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dictionary defining legal color names and corresponding color values.&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicing that datastructure. additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation. access both handles of a node at once. loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107211</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107211"/>
		<updated>2017-11-01T15:22:21Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extensions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension just like any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in Python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as shown in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuide( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embeded in SVG's style atribute. When a color is represented as integers they should be in the (0, 255) range, when represented as floats, they should be in the (0.0, 1.0) range.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;parseStyle( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Create a dictionary from the value of an inline style attribute.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatStyle( dict )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Format an inline style attribute from a dictionary.&lt;br /&gt;
;&amp;lt;code&amp;gt;isColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Determine if its a color we can use. If not, leave it unchanged.&lt;br /&gt;
;&amp;lt;coder&amp;gt;parseColor( c )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates a rgb int array.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColoria( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: int array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColorfa( a )&amp;lt;/code&amp;gt;&lt;br /&gt;
: float array to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3i( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: 3 ints to #rrggbb string.&lt;br /&gt;
;&amp;lt;code&amp;gt;formatColor3f( r, g, b )&amp;lt;/code&amp;gt;&lt;br /&gt;
: 3 floats to #rrggbb string.&lt;br /&gt;
&lt;br /&gt;
*svgcolors: a dictionary defining legal color names and corresponding color values&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicing that datastructure. additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation. access both handles of a node at once. loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107201</id>
		<title>Python modules for extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Python_modules_for_extensions&amp;diff=107201"/>
		<updated>2017-10-31T19:41:33Z</updated>

		<summary type="html">&lt;p&gt;Matyilona: Providing more detail on inkex.py&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Extensions]]&lt;br /&gt;
&lt;br /&gt;
These modules are provided as part of Inkscape and can be found in /usr/share/inkscape/extentions on GNU/Linux, ... on Windows, and ... on Mac OS X along with the extensions bundled with Inkscape. They can be &amp;lt;code&amp;gt;import&amp;lt;/code&amp;gt;ed from an extension as any other python module.&lt;br /&gt;
&lt;br /&gt;
== inkex.py ==&lt;br /&gt;
&lt;br /&gt;
This module encapsulates the basic behavior of a script extension, allowing the author to concentrate on manipulating the SVG data. It relies on [http://lxml.de/tutorial.html &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;] to work with the XML tree. inkex.py was originally designed to provide the Effect (filter) extension type, but has been used for Input/Output extensions simply by overriding additional class methods.&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
inkex.py provides the following functions:&lt;br /&gt;
;&amp;lt;code&amp;gt;errormsg( msg )&amp;lt;/code&amp;gt;&lt;br /&gt;
: End-user visible error message, it should always be used with translation: &amp;lt;code&amp;gt;inkex.errormsg(_(&amp;quot;This extension requires two selected paths&amp;quot;))&amp;lt;/code&amp;gt;&lt;br /&gt;
;&amp;lt;code&amp;gt;addNS( tag, ns=None )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the selected tag, with the namespace applied. The namespace is selected from a list supplied with the module.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class ===&lt;br /&gt;
&lt;br /&gt;
The most important part of inkex.py is the &amp;lt;code&amp;gt;Effect&amp;lt;/code&amp;gt; class. To implement an effect type extension in python see [[PythonEffectTutorial]]&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
;&amp;lt;code&amp;gt;effect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: You should overwrite this method with your own, as show in [[PythonEffectTutorial#Effect Extension Script]]&lt;br /&gt;
;&amp;lt;code&amp;gt;getElementById( id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the firs found element with given id, as a &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt; element.&lt;br /&gt;
;&amp;lt;code&amp;gt;getParentNode( node )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Returns the parent of &amp;lt;code&amp;gt;node&amp;lt;/code&amp;gt;. Probably the same as &amp;lt;code&amp;gt;node.getparent()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;?&lt;br /&gt;
;&amp;lt;code&amp;gt;createGuid( x, y, angle )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Creates guide at position (&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;), with angle &amp;lt;code&amp;gt;angle&amp;lt;/code&amp;gt;.&lt;br /&gt;
;&amp;lt;code&amp;gt;affect()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Actuate the script.&lt;br /&gt;
;&amp;lt;code&amp;gt;xpathSingle( path )&amp;lt;/code&amp;gt;&lt;br /&gt;
: An xpath wrapper to return a single node.&lt;br /&gt;
;&amp;lt;code&amp;gt;uniqueId( old_id )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return an id that is unique in the document given a proposed id, by appending random alphanumeric characters to it.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentWidth()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return width of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentHeight()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return height of document, as a string.&lt;br /&gt;
;&amp;lt;code&amp;gt;getDocumentUnit()&amp;lt;/code&amp;gt;&lt;br /&gt;
: Return a string representing the default unit for the document. Full list of possible units is defined in the module.&lt;br /&gt;
;&amp;lt;code&amp;gt;unittouu( string )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert given value (as a string, e.g: &amp;quot;4px&amp;quot;) to units used by the document. Returns float.&lt;br /&gt;
;&amp;lt;code&amp;gt;uutounit( value, unit )&amp;lt;/code&amp;gt;&lt;br /&gt;
: Convert a value (float) in document default units to given units.&lt;br /&gt;
&lt;br /&gt;
==== Properties ====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;&lt;br /&gt;
: DOM document, as a &amp;lt;code&amp;gt;lxml.etree&amp;lt;/code&amp;gt;. &lt;br /&gt;
;&amp;lt;code&amp;gt;selected&amp;lt;/code&amp;gt;&lt;br /&gt;
: A dict mapping ids to nodes, for all nodes selected in Inkscape.&lt;br /&gt;
;&amp;lt;code&amp;gt;doc_ids&amp;lt;/code&amp;gt;:&lt;br /&gt;
: A dict mapping ids to the constant 1, for all of the ids used in the original document. Does not get automatically updated when adding elements.&lt;br /&gt;
;&amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;&lt;br /&gt;
: Options passed to the script.&lt;br /&gt;
&lt;br /&gt;
== simplestyle.py ==&lt;br /&gt;
Provides methods for dealing with css data embeded in SVG's style=&amp;quot;&amp;quot; atribute&lt;br /&gt;
&lt;br /&gt;
*parseStyle(string): Create a dictionary from the value of an inline style attribute&lt;br /&gt;
*formatStyle(dict): Format an inline style attribute from a dictionary&lt;br /&gt;
*isColor(c): Determine if its a color we can use. If not, leave it unchanged.&lt;br /&gt;
*parseColor(c): Creates a rgb int array&lt;br /&gt;
*formatColoria(a): int array to #rrggbb&lt;br /&gt;
*formatColorfa(a): float array to #rrggbb&lt;br /&gt;
*formatColor3i(r,g,b): 3 ints to #rrggbb&lt;br /&gt;
*formatColor3f(r,g,b): 3 floats to #rrggbb&lt;br /&gt;
&lt;br /&gt;
*svgcolors: a dictionary defining legal color names and corresponding color values&lt;br /&gt;
&lt;br /&gt;
== simplepath.py ==&lt;br /&gt;
Provides functions to round trip svg path d=&amp;quot;&amp;quot; attribute data and a simple path format mimicing that datastructure. additional functions for scaling translating and rotating path data.&lt;br /&gt;
&lt;br /&gt;
== cubicsuperpath.py ==&lt;br /&gt;
An alternative path representation. access both handles of a node at once. loses a paths open/closed identity.&lt;br /&gt;
&lt;br /&gt;
== simpletransform.py ==&lt;br /&gt;
&lt;br /&gt;
Provides code to easily transform objects.&lt;br /&gt;
&lt;br /&gt;
*parseTransform&lt;br /&gt;
:Takes a string such as &amp;lt;tt&amp;gt;rotate(10)&amp;lt;/tt&amp;gt; and produces a transformation matrix. If you also supply an initial matrix, the new one will be composed with the old one.&lt;br /&gt;
:Available commands: &amp;lt;tt&amp;gt;translate, scale, rotate, skewX, skewY, matrix&amp;lt;/tt&amp;gt;. Other examples:&lt;br /&gt;
::matrix = parseTransform('rotate(10)')&lt;br /&gt;
::matrix = parseTransform('skewY(10)')&lt;br /&gt;
::matrix = parseTransform('translate(10 10)')&lt;br /&gt;
::matrix = parseTransform(' rotate(10)')&lt;br /&gt;
::matrix = parseTransform('translate(700,210) rotate(-30)')&lt;br /&gt;
&lt;br /&gt;
== pturtle.py ==&lt;br /&gt;
&lt;br /&gt;
Provides turtle graphics primitives with svg path data output&lt;br /&gt;
&lt;br /&gt;
== beziermisc.py ==&lt;br /&gt;
Utility functions for working with bezier curves&lt;br /&gt;
&lt;br /&gt;
== cspsubdiv.py ==&lt;br /&gt;
Decompose a path into polylines&lt;br /&gt;
&lt;br /&gt;
== ff*.py ==&lt;br /&gt;
&lt;br /&gt;
an obscure set of tools for dealing with musical scales.&lt;/div&gt;</summary>
		<author><name>Matyilona</name></author>
	</entry>
</feed>