Difference between revisions of "QuickDrawingAPI"
|Line 13:||Line 13:|
:Me. More specific: Inkscape users (designers) with a basic understanding of scripting
Revision as of 08:19, 6 July 2009
This page is meant as a proposal and a discussion platform for outlining a "quick drawing API" in Python. The purpose of this page is to summarize the needs of end-users ("designers") for a collection of Python-functions to assist in the quick drawing and manipulation of graphical objects on the canvas.
- 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.
- Create a series of pre-defined functions and classes that allow for direct creation and manipulation of drawing objects.
- 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
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;
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:
- An API connected to the core-functionality of Inkscape
- A series of classes that translate the requested functionality for other Python-classes that do the XML-handling.
Proposal for classes
Here is a quick, incomplete draft for the classes that would be needed. I'm not too familiar with the terminology of OOP, so if somebodies feels like making corrections: please!
- A location on the canvas.
- x: Real, indication x-position
- y:Real, indication x-position
- A node as part of a path.
- node: Point
- firstHandle: Point
- secondHandle: Point
- type: String, either:
- The handles get automatically re-calculated when the type of the node changes.
- Should the coordinates of the handles be relative to the node or absolute?
- Would it be handy to define the handles as polar coordinates, relative to the direction of the path and the node?
- generic drawing object on the canvas
- fill: Fill
- outline: Outline
- expands DrawingObject
- nodes: Array of Node-objects
- closed: Boolean indicating whether or not the path is closed
- expands DrawingObject
- centerPoint: Point
- startAngle: Real
- stopAngle: Real
- open: Boolean, indicates whether or not the cirlce is drawn open between stop and start angle
- pie: Boolean, indicates whether or not lines are drawn towards the center
- Object that holds an array of the objects that are selected.
- Content: Array of Drawing Objects