Difference between revisions of "Extension subsystem"

From Inkscape Wiki
Jump to navigation Jump to search
 
(26 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[Category:Extensions]]
[[Category:Extensions]]
{{Template:MovedToOtherSite|topic=Extension development|new_url=https://inkscape.gitlab.io/extensions/documentation/|new_site=GitLab}}
----
== General ==
== General ==
The Extension system is a way to add functionality to Inkscape.  The
The Extension system is a way to add functionality to Inkscape.  The
design of the extension system follows the bridge design pattern,
design of the extension system is similar to the [http://en.wikipedia.org/wiki/Bridge_pattern bridge design pattern],
breaking apart the functionality that is being provided, and the
breaking apart the functionality that is being provided, and the
implementation of that functionality.  The term extension is used to
implementation of that functionality.  The term ''extension'' is used to
describe all of this, the functionality and the implementation.
describe all of this, the functionality and the implementation.
 
== Functionality Provided ==
== Functionality Provided ==
There are several types of functionality provided by the extensions
There are several types of functionality provided by the extensions
system today, and more are slated for the future.
system today, and more are slated for the future.
-- Input.  Input extensions take data from a file and bring it into
* '''Input.''' Input extensions take data from a file and bring it into Inkscape.  Even reading SVG files (Inkscape's native format) is implemented as an internal extension.  Input extensions can be chained so that extensions can be created that don't make it all the way to SVG directly. ([http://inkscape.modevia.com/doxygen/html/classInkscape_1_1Extension_1_1Input.php code reference])
Inkscape.  Even reading SVG files (Inkscape's native format) is
* '''Output.''' Output extensions take the data from Inkscape and turn it into a file.  SVG Output is an internal extension.  Output extensions can also be chained. ([http://inkscape.modevia.com/doxygen/html/classInkscape_1_1Extension_1_1Output.php code reference])
implemented as an internal extension.  Input extensions can be chained
* '''Effect.''' Effects are extension that take a document, and possibly a selection, and change it in some way.  This could be anything from changing colors to generating fractals.  These are similar to Filters in The GIMP. ([http://inkscape.modevia.com/doxygen/html/classInkscape_1_1Extension_1_1Effect.php code reference])
so that extensions can be created that don't make it all the way to SVG
* '''Print.'''  Print are extensions that require a little more work from Inkscape itself.  They provide a set of functions that allow Inkscape to 'render' the document onto the extension.  These are the most complex to implement, but can provide the most functionality to a potential developer of extensions. ([http://inkscape.modevia.com/doxygen/html/classInkscape_1_1Extension_1_1Print.php code reference])
directly.
* '''Path Effects.''' Path effects provide a way to change a path.  They allow a user to edit a path using the standard Inkscape path editing tools, but then have it look differently than just a line.  This could include everything from adding hash marks to making the line look like it's on fire. (not in Doxygen yet)
-- Output.  Output extensions take the data from Inkscape and turn it
* '''Tools.''' Tools are the ways that you draw in Inkscape.  Rectangle tool, circle tool, star tool...  the goal is to eventually have the ability to add tools as extensions. (no code)
into a file.  SVG Output is an internal extension.  Output extensions
can also be chained.
-- Effects.  Effects are extension that take a document, and possibly a
selection, and change it in some way.  This could be anything from
changing colors to generating fractals.  These are similar to Filters in
The GIMP.
-- Path Effects.  Path effects provide a way to change a path.  They
allow a user to edit a path using the standard Inkscape path editing
tools, but then have it look differently than just a line.  This could
include everything from adding hash marks to making the line look like
it's on fire.
-- Tools.  Tools are the ways that you draw in Inkscape.  Rectangle
tool, circle tool, star tool...  the goal is to eventually have the
ability to add tools as extensions.


== Implementation Types ==
== Implementation Types ==
While the functionality that the extension provides is described above,
While the functionality that the extension provides is described above, how that gets done is a different story.  The Inkscape extensions system allows for programmers to implement their extension in  a variety of ways, trying to match their particular skillset.
how that gets done is a different story.  The Inkscape extensions system
* '''Internal.''' Any extension type can be implemented in C or C++ and directly linked into the Inkscape codebase.  While in general the goal is to move as much out of the main Inkscape binary, this makes sense for many extensions including things like SVG input/output.
allows for programmers to implement their extension in  a variety of
* '''Plugins.'''  Similar to internal extensions (can be implement in C or C++) but linked as a separate library that is dynamically loaded at runtime.
ways, trying to match their particular skillset.
* '''Scripts.''' Scripts are where Inkscape uses standard in and standard out on an external executable to implement the functionality.  This allow Inkscape to reuse a variety of utilities that already do format conversion or implement cool things in SVG.  Typically the scripts that are effects use a SVG DOM library in their programming language of choice.
-- Internal.  Any extension type can be implement in C or C++ and
* '''XSLT.''' This implementation is done in the XSLT language, and uses libxml's XSLT parser that is already linked with Inkscape.
directly linked into the Inkscape codebase.  While in general the goal
* '''DOM Scripts.''' As Inkscape finishes its DOM implementation the goal will be to provide this directly to scripts.  This will allow for faster execution, but also other access to Inkscape's internals and algorithms.
is to move as much out of the main Inkscape binary, this makes sense for
 
many extensions including things like SVG input/output.
== Maturity ==
-- Scripts.  Scripts are where Inkscape uses standard in and standard
The extension system is currently able to provide functionality from the '''Input''', '''Output''', and '''Effects''' categories. A plan has been scoped for the implementation of '''Path Effects''' but work has not yet begun. I am not aware of the status of the '''Tools''' functionality described above.
out on an external executable to implement the functionality.  This
 
allow Inkscape to reuse a variety of utilities that already do format
'''Internal''' and '''Script''' implementations are available to the developer. Bob Jamison (aka ishmal) has done a large amount of work toward '''DOM Scripts''' but there are not yet any working examples. I am not aware of the status of the '''XSLT''' implementation.  '''Note:''' XSLT at this time appears to support input and output filtering, but not effects filters (i.e. there is no implementation of Inkscape::Extension::Implementation::XSLT::effect(), only ::open() and ::save() )
conversion or implement cool things in SVG.  Typically the scripts that
are effects use a SVG DOM library in their programming language of
choice.
-- XSLT.  This implementation is done in the XSLT language, and uses
libxml's XSLT parser that is already linked with Inkscape.
-- DOM Scripts.  As Inkscape finishes its DOM implementation the goal
will be to provide this directly to scripts.  This will allow for faster
execution, but also other access to Inkscape's internals and algorithms.


== See Also ==
== See Also ==
http://sourceforge.net/mailarchive/message.php?msg_id=15742559
* [[ScriptingHOWTO]]: an explanation of the details for creating an extension with the Script implementation.
* [[MakingAnINX]]: every Extension needs an INX file.
* [http://article.gmane.org/gmane.comp.graphics.inkscape.devel/16210 A message from Ted Gould] describing the functionality and implementation types.
* [http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/doc/extension_system.txt  The original extension architecture document from inkscape svn.] It would be good to look through this document and move pertinent facts onto this page.
* [[Extension_Interpreters | Extension Interpreters]] for info about supported interpreters and how to deal with different interpreter versions

Latest revision as of 19:54, 3 February 2023


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

You can now find related information at GitLab.

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


General

The Extension system is a way to add functionality to Inkscape. The design of the extension system is similar to the bridge design pattern, breaking apart the functionality that is being provided, and the implementation of that functionality. The term extension is used to describe all of this, the functionality and the implementation.

Functionality Provided

There are several types of functionality provided by the extensions system today, and more are slated for the future.

  • Input. Input extensions take data from a file and bring it into Inkscape. Even reading SVG files (Inkscape's native format) is implemented as an internal extension. Input extensions can be chained so that extensions can be created that don't make it all the way to SVG directly. (code reference)
  • Output. Output extensions take the data from Inkscape and turn it into a file. SVG Output is an internal extension. Output extensions can also be chained. (code reference)
  • Effect. Effects are extension that take a document, and possibly a selection, and change it in some way. This could be anything from changing colors to generating fractals. These are similar to Filters in The GIMP. (code reference)
  • Print. Print are extensions that require a little more work from Inkscape itself. They provide a set of functions that allow Inkscape to 'render' the document onto the extension. These are the most complex to implement, but can provide the most functionality to a potential developer of extensions. (code reference)
  • Path Effects. Path effects provide a way to change a path. They allow a user to edit a path using the standard Inkscape path editing tools, but then have it look differently than just a line. This could include everything from adding hash marks to making the line look like it's on fire. (not in Doxygen yet)
  • Tools. Tools are the ways that you draw in Inkscape. Rectangle tool, circle tool, star tool... the goal is to eventually have the ability to add tools as extensions. (no code)

Implementation Types

While the functionality that the extension provides is described above, how that gets done is a different story. The Inkscape extensions system allows for programmers to implement their extension in a variety of ways, trying to match their particular skillset.

  • Internal. Any extension type can be implemented in C or C++ and directly linked into the Inkscape codebase. While in general the goal is to move as much out of the main Inkscape binary, this makes sense for many extensions including things like SVG input/output.
  • Plugins. Similar to internal extensions (can be implement in C or C++) but linked as a separate library that is dynamically loaded at runtime.
  • Scripts. Scripts are where Inkscape uses standard in and standard out on an external executable to implement the functionality. This allow Inkscape to reuse a variety of utilities that already do format conversion or implement cool things in SVG. Typically the scripts that are effects use a SVG DOM library in their programming language of choice.
  • XSLT. This implementation is done in the XSLT language, and uses libxml's XSLT parser that is already linked with Inkscape.
  • DOM Scripts. As Inkscape finishes its DOM implementation the goal will be to provide this directly to scripts. This will allow for faster execution, but also other access to Inkscape's internals and algorithms.

Maturity

The extension system is currently able to provide functionality from the Input, Output, and Effects categories. A plan has been scoped for the implementation of Path Effects but work has not yet begun. I am not aware of the status of the Tools functionality described above.

Internal and Script implementations are available to the developer. Bob Jamison (aka ishmal) has done a large amount of work toward DOM Scripts but there are not yet any working examples. I am not aware of the status of the XSLT implementation. Note: XSLT at this time appears to support input and output filtering, but not effects filters (i.e. there is no implementation of Inkscape::Extension::Implementation::XSLT::effect(), only ::open() and ::save() )

See Also