Inkscape
Vector Graphics Editor
|
Implementation class of the GIMP gradient plugin. More...
#include <gimpgrad.h>
Public Member Functions | |
bool | load (Inkscape::Extension::Extension *module) override |
void | unload (Inkscape::Extension::Extension *module) override |
std::unique_ptr< SPDocument > | open (Inkscape::Extension::Input *module, char const *filename, bool is_importing) override |
Actually open the gradient and turn it into an SPDocument. | |
![]() | |
Implementation ()=default | |
virtual | ~Implementation ()=default |
virtual ImplementationDocumentCache * | newDocCache (Inkscape::Extension::Extension *, SPDesktop *) |
Create a new document cache object. | |
virtual bool | check (Inkscape::Extension::Extension *) |
Verify any dependencies. | |
virtual bool | cancelProcessing () |
virtual void | commitDocument () |
virtual std::unique_ptr< SPDocument > | new_from_template (Inkscape::Extension::Template *) |
virtual void | get_template_presets (const Template *tmod, TemplatePresets &presets) const |
virtual void | resize_to_template (Inkscape::Extension::Template *tmod, SPDocument *doc, SPPage *page) |
virtual bool | match_template_size (Inkscape::Extension::Template *tmod, double width, double height) |
virtual void | save (Inkscape::Extension::Output *, SPDocument *, gchar const *) |
Find out information about the file. | |
virtual void | export_raster (Inkscape::Extension::Output *module, const SPDocument *doc, std::string const &png_file, gchar const *filename) |
Convert from PNG to raster format. | |
virtual Gtk::Widget * | prefs_effect (Inkscape::Extension::Effect *module, SPDesktop *desktop, sigc::signal< void()> *changeSignal, ImplementationDocumentCache *docCache) |
Find out information about the file. | |
virtual void | effect (Inkscape::Extension::Effect *, ExecutionEnv *, SPDesktop *, ImplementationDocumentCache *) |
virtual void | effect (Inkscape::Extension::Effect *, ExecutionEnv *, SPDocument *document) |
virtual bool | apply_filter (Inkscape::Extension::Effect *module, SPItem *item) |
virtual unsigned | setup (Inkscape::Extension::Print *) |
virtual unsigned | set_preview (Inkscape::Extension::Print *) |
virtual unsigned | begin (Inkscape::Extension::Print *, SPDocument *) |
virtual unsigned | finish (Inkscape::Extension::Print *) |
virtual bool | textToPath (Inkscape::Extension::Print *) |
Tell the printing engine whether text should be text or path. | |
virtual bool | fontEmbedded (Inkscape::Extension::Print *) |
Get "fontEmbedded" param, i.e. | |
virtual unsigned | bind (Inkscape::Extension::Print *, Geom::Affine const &, float) |
virtual unsigned | release (Inkscape::Extension::Print *) |
virtual unsigned | fill (Inkscape::Extension::Print *, Geom::PathVector const &, Geom::Affine const &, SPStyle const *, Geom::OptRect const &, Geom::OptRect const &, Geom::OptRect const &) |
virtual unsigned | stroke (Inkscape::Extension::Print *, Geom::PathVector const &, Geom::Affine const &, SPStyle const *, Geom::OptRect const &, Geom::OptRect const &, Geom::OptRect const &) |
virtual unsigned | image (Inkscape::Extension::Print *, unsigned char *, unsigned int, unsigned int, unsigned int, Geom::Affine const &, SPStyle const *) |
virtual unsigned | text (Inkscape::Extension::Print *, char const *, Geom::Point const &, SPStyle const *) |
virtual void | processPath (Inkscape::XML::Node *) |
virtual void | setDetachBase (bool detach) |
If detach = true, when saving to a file, don't store URIs relative to the filename. | |
Static Public Member Functions | |
static void | init () |
Implementation class of the GIMP gradient plugin.
This mostly just creates a namespace for the GIMP gradient plugin today.
Definition at line 22 of file gimpgrad.h.
|
static |
Definition at line 250 of file gimpgrad.cpp.
References Inkscape::Extension::build_from_mem().
Referenced by Inkscape::Extension::init().
|
overridevirtual |
Reimplemented from Inkscape::Extension::Implementation::Implementation.
Definition at line 32 of file gimpgrad.cpp.
|
overridevirtual |
Actually open the gradient and turn it into an SPDocument.
module | The input module being used |
filename | The filename of the gradient to be opened |
GIMP gradients are pretty simple (atleast the newer format, this function does not handle the old one yet). They start out with the like "GIMP Gradient", then name it, and tell how many entries there are. This function currently ignores the name and the number of entries just reading until it fails.
The other small piece of trickery here is that GIMP gradients define a left position, right position and middle position. SVG gradients have no middle position in them. In order to handle this case the left and right colors are averaged in a linear manner and the middle position is used for that color.
That is another point, the GIMP gradients support many different types of gradients – linear being the most simple. This plugin assumes that they are all linear. Most GIMP gradients are done this way, but it is possible to encounter more complex ones – which won't be handled correctly.
The one optimization that this plugin makes that if the right side of the previous segment is the same color as the left side of the current segment, then the second one is dropped. This is often done in GIMP gradients and they are not necissary in SVG.
What this function does is build up an SVG document with a single linear gradient in it with all the stops of the colors in the GIMP gradient that is passed in. This document is then turned into a document using the sp_document_from_mem
. That is then returned to Inkscape.
Reimplemented from Inkscape::Extension::Implementation::Implementation.
Definition at line 114 of file gimpgrad.cpp.
References SPDocument::createNewDocFromMem(), Inkscape::IO::dump_fopen_call(), end, Inkscape::IO::fopen_utf8name(), Inkscape::Extension::Internal::stop_svg(), streq(), and strneq().
|
overridevirtual |
Reimplemented from Inkscape::Extension::Implementation::Implementation.
Definition at line 37 of file gimpgrad.cpp.