QuickDrawingAPI

From Inkscape Wiki
Revision as of 09:49, 4 July 2009 by Mvdv (talk | contribs) (proposal and discussion for a "Quick Drawing Python API")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page is meant as a proposal and a discussion platform for outlining a "quick drawing API" in Python.

Summary

Problem
Creating an effect or "macro" in Inkscape is possible using Python, but the present tools available in Python all require XML-handling. This is contra-intuitive for a drawing program and imposes a barrier to users for creating new tools.
Solution
Create a series of pre-defined functions and classes that allow for direct creation and manipulation of drawing objects.
Benefits
Easier creation of "macros" in Inkscape will encourage designers to write and share the tools they need, thereby enhancing Inkscape functionality quickly and increasing the contribution of the community of users. This has for example happened with Blender, where the community has created a vast set of tools(among which quite many wizards) for creating and modifying the 3d models.
target users
Me. More specific: Inkscape users (designers) with a basic understanding of scripting, for example from JavaScript/HTML/ActionScript, but without the need or desire to digg deep into code development.

Examples

Before setting up the "API", I'd like to give an example of what I envision using pseudo-code. Excuse me if it looks too POSIX-style and too little Python.

myNewShape=new Path();
myNewShape.addNode([0,0]);
myNewShape.addNode([1,0]);
myNewShape.addNode([0,1]);
myNewShape.closed=true;
myNewShape.fill.fillColor=#FF0000FF;


Technical notes

I have no clue about how this all should be implemented. I see basically two options, please correct me if I use the wrong wording:

  1. An API connected to the core-functionality of Inkscape
  2. A series of classes that translate the requested functionality for other Python-classes that do the XML-handling.