summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e767711)
raw | patch | inline | side by side (parent: e767711)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 19 Aug 2007 12:24:42 +0000 (12:24 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 19 Aug 2007 12:24:42 +0000 (12:24 +0000) |
src/live_effects/lpe-skeleton.cpp | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-skeleton.h | [new file with mode: 0644] | patch | blob |
diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp
--- /dev/null
@@ -0,0 +1,109 @@
+#define INKSCAPE_LPE_SKELETON_CPP\r
+/** \file\r
+ * SVG <skeleton> implementation, used as an example for a base starting class\r
+ * when implementing new LivePathEffects.\r
+ *\r
+ * In vi, three global search-and-replaces will let you rename everything\r
+ * in this and the .h file:\r
+ *\r
+ * :%s/SKELETON/YOURNAME/g\r
+ * :%s/Skeleton/Yourname/g\r
+ * :%s/skeleton/yourname/g\r
+ */\r
+/*\r
+ * Authors:\r
+ * Johan Engelen\r
+*\r
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/lpe-skeleton.h"\r
+#include "display/curve.h"\r
+#include <libnr/n-art-bpath.h>\r
+\r
+// You might need to include other 2geom files. You can add them here:\r
+#include <2geom/path.h>\r
+\r
+namespace Inkscape {\r
+namespace LivePathEffect {\r
+\r
+LPESkeleton::LPESkeleton(LivePathEffectObject *lpeobject) :\r
+ Effect(lpeobject),\r
+ // initialise your parameters here:\r
+ number(_("Float parameter"), _("just a real number like 1.4!"), "svgname", &wr, this, 1.2)\r
+{\r
+ // register all your parameters here, so Inkscape knows which parameters this effect has:\r
+ registerParameter( dynamic_cast<Parameter *>(&number) );\r
+}\r
+\r
+LPESkeleton::~LPESkeleton()\r
+{\r
+\r
+}\r
+\r
+\r
+/* ########################\r
+ * Choose to implement one of the doEffect functions. You can delete or comment out the others.\r
+*/\r
+\r
+/*\r
+void\r
+LPESkeleton::doEffect (SPCurve * curve)\r
+{\r
+ // spice this up to make the effect actually *do* something!\r
+}\r
+\r
+NArtBpath *\r
+LPESkeleton::doEffect (NArtBpath * path_in)\r
+{\r
+ NArtBpath *path_out;\r
+ unsigned ret = 0;\r
+ while ( path_in[ret].code != NR_END ) {\r
+ ++ret;\r
+ }\r
+ unsigned len = ++ret;\r
+ path_out = g_new(NArtBpath, len);\r
+\r
+ memcpy(path_out, path_in, len * sizeof(NArtBpath)); // spice this up to make the effect actually *do* something!\r
+\r
+ return path_out;\r
+}\r
+\r
+std::vector<Geom::Path>\r
+LPESkeleton::doEffect (std::vector<Geom::Path> & path_in)\r
+{\r
+ std::vector<Geom::Path> path_out;\r
+\r
+ path_out = path_in; // spice this up to make the effect actually *do* something!\r
+\r
+ return path_out;\r
+}\r
+*/\r
+\r
+Geom::Piecewise<Geom::D2<Geom::SBasis> >\r
+LPESkeleton::doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in)\r
+{\r
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > output;\r
+\r
+ output = pwd2_in; // spice this up to make the effect actually *do* something!\r
+\r
+ return output;\r
+}\r
+\r
+/* ######################## */\r
+\r
+}; //namespace LivePathEffect\r
+}; /* namespace Inkscape */\r
+\r
+/*\r
+ Local Variables:\r
+ mode:c++\r
+ c-file-style:"stroustrup"\r
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
+ indent-tabs-mode:nil\r
+ fill-column:99\r
+ End:\r
+*/\r
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r
diff --git a/src/live_effects/lpe-skeleton.h b/src/live_effects/lpe-skeleton.h
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef INKSCAPE_LPE_SKELETON_H\r
+#define INKSCAPE_LPE_SKELETON_H\r
+\r
+/** \file\r
+ * SVG <skeleton> implementation, see sp-skeleton.cpp.\r
+ */\r
+\r
+/*\r
+ * Authors:\r
+ * Johan Engelen\r
+*\r
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/effect.h"\r
+#include "live_effects/parameter/parameter.h"\r
+#include "live_effects/parameter/point.h"\r
+\r
+namespace Inkscape {\r
+namespace LivePathEffect {\r
+\r
+class LPESkeleton : public Effect {\r
+public:\r
+ LPESkeleton(LivePathEffectObject *lpeobject);\r
+ ~LPESkeleton();\r
+\r
+// Choose to implement one of the doEffect functions. You can delete or comment out the others.\r
+// void doEffect (SPCurve * curve);\r
+// NArtBpath * doEffect (NArtBpath * path_in);\r
+// std::vector<Geom::Path> doEffect (std::vector<Geom::Path> & path_in);\r
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);\r
+\r
+private:\r
+ // add the parameters for your effect here:\r
+ RealParam number;\r
+ // there are all kinds of parameters. Check the /live_effects/parameter directory which types exist!\r
+\r
+ LPESkeleton(const LPESkeleton&);\r
+ LPESkeleton& operator=(const LPESkeleton&);\r
+};\r
+\r
+} //namespace LivePathEffect\r
+} //namespace Inkscape\r
+\r
+#endif\r