Difference between revisions of "Extension architecture proposals"

From Inkscape Wiki
Jump to navigation Jump to search
 
(40 intermediate revisions by 17 users not shown)
Line 1: Line 1:
{{Template:MovedToOtherSite|topic=Extension architecture|new_url=https://inkscape.gitlab.io/extensions/documentation/|new_site=GitLab}}
----
Please place your extension architecture proposals here. Everyone will review them and we will decided a course of action after we release 0.38.
Please place your extension architecture proposals here. Everyone will review them and we will decided a course of action after we release 0.38.
* [[ExtensionArchProposal]]


=== Tasks ===
=== Tasks ===
Line 20: Line 26:
* Create web tool for contributing new Extensions
* Create web tool for contributing new Extensions


=== Terminology ===
* Extension - An extension is something that extends the functionality of Inkscape without being directly part of the core.  This implies that it should be easy to remove or add, and nothing in the core should depend on it directly.
* Plug-in - An extension that is implemented through a loadable library.  This is a .o file on Unix-like systems or a .dll on Win32.  The libraries should not be loaded until they are used.
** PlugIns discussion
* Script - A script is a type of extension that is implemented through an external program that recieves and sets SVG data through files and pipes.  This allows Inkscape to use programs that handle SVG but are targeted differently seemlessly inside of Inkscape.
** ScriptingLanguages discussion
* Module - As far as I am aware the only definition of this word in Inkscape is that it was previously used to describe an extension.  The word is deprecated ;)
=== Inkscape Extension API ===


Describe things that one may want to use the API for:
=== Requirements ===


* Ability to load/print/save/close documents
We would like the extension system to provide the following capabilities:
    SPDocument * sp_file_open (gchar * uri, Inkscape::Extension::Input * ext)
    bool sp_file_save (SPDocument * doc, gchar * uri, Inkscape::Extension::Output * ext)
    bool sp_print_doc (SPDOcument * doc)
* Access to the document's SVG::DOM object hierarchy
    array  getElements(string element_name)
    string getElementName()
    string getElementByID(string id)
    string getElementID()
    hash  getAttributes()
    string getAttribute(string attribute)
    bool  SetAttribute(string name, string value)
    bool  SetAttributes(hash)
    bool  hasChildren()
    array  getChildren()
    obj    getFirstChild()
    obj    getLastChild()
    array  getSiblings()
    obj    getNextSibling()
    obj    getPrevSibling()
    int    getChildIndex()
    obj    getChildAtIndex(int index)
    obj    getParent()
    array  getParents()
    bool  isAncestor(obj)
    bool  isDescendant(obj)
    cdata  getCDATA()
* Access to all Inkscape verbs
* Access to preferences
* Access to global def's
** Gradients
** Markers
** Patterns
* Access to share resources (clipart, templates, etc.)
* Extension based variables


These are the variables that control settings for the individual extension.  Things that are held internally, but should be saved with the Inkscape preferences.  These are:
* Uses a general language binding system so it's easy to add new language binding support
* Allows direct interaction with the document object model including changing styles, adding/removing defs and elements, etc.
* Allows some limited interaction with the Inkscape UI such as manipulating grids, overlays, etc.
* Allows direct interaction with file load/save/export/print subsystem
* Guaranteed to work properly with the undo system, even if the extension is not written carefully
* Well documented so is easy for people to learn how to make new extensions
* Each plugin can be implemented, distributed, and managed independently of the core project
* Should be easy to start learning how to create new plugins
* Icons, buttons, and other UI elements for plugins fit seamlessly into main application GUI
* User can easily select which plugins to automatically load into application at startup
* Loading of plugins shall not seriously slow startup time or make a major impact on memory footprint
* Failure of a plugin shall not leave the drawing in an inconsistent state
* Main application must gracefully recover from plugin crashes or other serious problems with plugin execution
* Dependencies for particular plugins must be clearly identified for user if missing


    get_param (gchar * name, [bool, int, gchar *] data)
=== Extension ideas ===


: This function gets the variable by the name 'name' with the data in 'data'. It can be a boolean, integer or a string.
*Plugin to send image to sign making peripherals like the Graphtec or Summa vinyl cutters' and printers'. Adobe Illustrator has such a thing so why not Insckape too?:)
* Cross stitch generator (http://hawthorn.csse.monash.edu.au/~njh/programming/cross-stitch/)
* Celtic knot editor: Using the standard winding number algorithm for Celtic knots build an interactive editor that forms the basic structure of the knots, allowing the user to edit the curve once generated.  (Possible issue - getting the over/under rules correct)  Douglas Zongker's Celtic Knot Thingy is a possible resource: http://isotropic.org/uw/knot/
* mail-merge
* Integrate a capture of a Blender3D frame and then process that bitmap. From a Blender-viewer window?  From a simpler viewer?  Not from a screen capture...higher resolution is desired...
* Socket connection to other apps instead of file-based, where the state of socket connections will be autosaved and restorable after a crash...(since such on the fly work may not be easy to recreate then)
* 3-d rotate - this is a really cool Kai (Kai's Vector Tools/Effects) plug-in for Illustrator
* Inkify - it would be cool to have a plug-in that would take a normal object and make it look like it was drawn with ink.
* Copy Adobe Illustrator's filters (punkify, bloat, calligraphize, etc)
* Copy Dia's plugins
* Look at Karbon14's plugins
* PDF and Postscript import that converts all the type into lines as well as the included postscript vector objects and bitmaps
* Randomize Size and Rotation of Objects
* Create Cluster of objects from one seed with variable quantity, random distribution (noise types, gaussian, etc), variable rotation, opacity, and size
* Zoom effect on shapes. Create an option where a zoom-like effect can be applied to a shape or set of shapes where more shapes are made larger and larger from the central anchor point of the shape(s) passed to this plugin
* Color effects: Invert, Desaturate, etc. http://gimp-savvy.com/BOOK/index.html?node54.html


    set_param (gchar * name, [bool, int, gchar *] data)
[[Category:Developer Discussion]]


: This function sets the variable by the name 'name' with the data in 'data'.  It can be a boolean, integer or a string.  In the case of the string it is copied.
=== Existing extensions not bundled with Inkscape ===


For examples of API functions, see the perl SVG, SVG::DOM, et al modules
* [http://www.inkscapeforum.com/viewtopic.php?f=22&t=336 Trace Setup], prepares a document for tracing a bitmap image
* [http://www.iki.fi/pav/software/textext/index.html textext], re-editable LaTeX objects in Inkscape
* [http://www.kono.cis.iwate-u.ac.jp/~arakit/inkscape/inklatex.html InkLaTeX], simple drawing LaTeX text on Inkscape
* [http://sourceforge.net/projects/animeasy animEasy], easy 2D animations


=== Inkscape Extension Archive Network ===
=== Inkscape Extension Archive Network ===
Line 100: Line 93:
   * Establish forum for thanks and positive feedback
   * Establish forum for thanks and positive feedback
   * Like freshmeat/sourceforge, report on # downloads, vitality, etc.
   * Like freshmeat/sourceforge, report on # downloads, vitality, etc.
=== Extension Architechture Feature Wishlist ===
* View stderr for external processes on failure (DONE)
* Report reason (what deps are missing) for being disabled on attempted use
* multiline text input widget
* enumerated values input widget (dropdownlistbox) (would make effects more self documenting in some cases)
* mutually exclusive parameter groups (tabbed notebooks)
* multiline text label for use instructions
* consider extension API rework. Current problems: possible perfomance issues because file IO and full document parsing at extension end. Also, access to internal inkscape functions is limited to invoking another copy of inkscape, wich leads again to long execution times and lack of flexibility. Proposed change: two-way communication via stdin/stdout in XML protocol, wich must allow partial document modification and allow access to inkscape internal functions, such as bounding box calculation, bezier curves subdivision, etc.
=== See Also ===
* [[ScriptingHOWTO]]
* [http://sourceforge.net/mailarchive/message.php?msg_id=2057634 Ted's Plug-in Research from [[SodiPodi]]]
[[Category:Developer Discussion]]
[[Category:Extensions]]
[[Category:Wiki Attic]]

Latest revision as of 19:51, 3 February 2023

The Inkscape Wiki is no longer used to host information about Extension architecture.

You can now find related information at GitLab.

This page is kept for historical reasons, e.g. to document specific decisions in Inkscape development.


Please place your extension architecture proposals here. Everyone will review them and we will decided a course of action after we release 0.38.

Tasks

Design Phase:

  • Flesh out each category of functions in the API with ideas for what the functions should be
  • Solidify the underlying Extension infrastructure [Ted]
  • Create an example Extension package
  • Write a specification document, including:
    • Overview of Inkscape Extensions
    • Creating an Extension
    • Registering an Extension
    • Custom Extension Preferences
    • Extension API Definition

Implementation Phase:

  • Implement Extension API
  • Implement an Extension registry
  • Create Extension preferences dialog
  • Create web tool for contributing new Extensions


Requirements

We would like the extension system to provide the following capabilities:

  • Uses a general language binding system so it's easy to add new language binding support
  • Allows direct interaction with the document object model including changing styles, adding/removing defs and elements, etc.
  • Allows some limited interaction with the Inkscape UI such as manipulating grids, overlays, etc.
  • Allows direct interaction with file load/save/export/print subsystem
  • Guaranteed to work properly with the undo system, even if the extension is not written carefully
  • Well documented so is easy for people to learn how to make new extensions
  • Each plugin can be implemented, distributed, and managed independently of the core project
  • Should be easy to start learning how to create new plugins
  • Icons, buttons, and other UI elements for plugins fit seamlessly into main application GUI
  • User can easily select which plugins to automatically load into application at startup
  • Loading of plugins shall not seriously slow startup time or make a major impact on memory footprint
  • Failure of a plugin shall not leave the drawing in an inconsistent state
  • Main application must gracefully recover from plugin crashes or other serious problems with plugin execution
  • Dependencies for particular plugins must be clearly identified for user if missing

Extension ideas

  • Plugin to send image to sign making peripherals like the Graphtec or Summa vinyl cutters' and printers'. Adobe Illustrator has such a thing so why not Insckape too?:)
  • Cross stitch generator (http://hawthorn.csse.monash.edu.au/~njh/programming/cross-stitch/)
  • Celtic knot editor: Using the standard winding number algorithm for Celtic knots build an interactive editor that forms the basic structure of the knots, allowing the user to edit the curve once generated. (Possible issue - getting the over/under rules correct) Douglas Zongker's Celtic Knot Thingy is a possible resource: http://isotropic.org/uw/knot/
  • mail-merge
  • Integrate a capture of a Blender3D frame and then process that bitmap. From a Blender-viewer window? From a simpler viewer? Not from a screen capture...higher resolution is desired...
  • Socket connection to other apps instead of file-based, where the state of socket connections will be autosaved and restorable after a crash...(since such on the fly work may not be easy to recreate then)
  • 3-d rotate - this is a really cool Kai (Kai's Vector Tools/Effects) plug-in for Illustrator
  • Inkify - it would be cool to have a plug-in that would take a normal object and make it look like it was drawn with ink.
  • Copy Adobe Illustrator's filters (punkify, bloat, calligraphize, etc)
  • Copy Dia's plugins
  • Look at Karbon14's plugins
  • PDF and Postscript import that converts all the type into lines as well as the included postscript vector objects and bitmaps
  • Randomize Size and Rotation of Objects
  • Create Cluster of objects from one seed with variable quantity, random distribution (noise types, gaussian, etc), variable rotation, opacity, and size
  • Zoom effect on shapes. Create an option where a zoom-like effect can be applied to a shape or set of shapes where more shapes are made larger and larger from the central anchor point of the shape(s) passed to this plugin
  • Color effects: Invert, Desaturate, etc. http://gimp-savvy.com/BOOK/index.html?node54.html

Existing extensions not bundled with Inkscape

  • Trace Setup, prepares a document for tracing a bitmap image
  • textext, re-editable LaTeX objects in Inkscape
  • InkLaTeX, simple drawing LaTeX text on Inkscape
  • animEasy, easy 2D animations

Inkscape Extension Archive Network

Initially, distributing extensions with Inkscape itself will be okay but ultimately for them to truly be extensions they should exist external to the core Inkscape project, which means we need some way to receive and manage contributions. Perl's CPAN provides an excellent model for how this type of module-contribution system can be made to work. Some important characteristics of CPAN worth adopting here:

  * Indexes of best items are available (e.g. 'best of')
  * Redundant modules are tolerated
  * Automate testing of included test suites on various platforms
  * Naming requirements to be included in indexes
  * Removal of malicious items
  * Manual application for user id on the system
  * Documentation for each module is online and nicely formatted
  * Integrated bug tracking system
  * Need to divide 'development' and 'stable'
  * Need to identify poor style, over-complexity.
  * Feedback to author should be personal so avoids public ranting
  * Use of review forms instead of freeform feedback?
  * Use of per-module discussion forums?
  * Establish forum for thanks and positive feedback
  * Like freshmeat/sourceforge, report on # downloads, vitality, etc.

Extension Architechture Feature Wishlist

  • View stderr for external processes on failure (DONE)
  • Report reason (what deps are missing) for being disabled on attempted use
  • multiline text input widget
  • enumerated values input widget (dropdownlistbox) (would make effects more self documenting in some cases)
  • mutually exclusive parameter groups (tabbed notebooks)
  • multiline text label for use instructions
  • consider extension API rework. Current problems: possible perfomance issues because file IO and full document parsing at extension end. Also, access to internal inkscape functions is limited to invoking another copy of inkscape, wich leads again to long execution times and lack of flexibility. Proposed change: two-way communication via stdin/stdout in XML protocol, wich must allow partial document modification and allow access to inkscape internal functions, such as bounding box calculation, bezier curves subdivision, etc.

See Also