summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9dcc516)
raw | patch | inline | side by side (parent: 9dcc516)
author | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 18 May 2008 20:47:27 +0000 (20:47 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 18 May 2008 20:47:27 +0000 (20:47 +0000) |
src/live_effects/Makefile_insert | patch | blob | history | |
src/live_effects/effect.cpp | patch | blob | history | |
src/live_effects/effect.h | patch | blob | history | |
src/live_effects/lpe-perp_bisector.cpp | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-perp_bisector.h | [new file with mode: 0644] | patch | blob |
index c476948b6c8dbe6c2a13ab3db431f19399ea5924..7e8a9e3a37326ad3b1d6e85d4f900645dcb36bbe 100644 (file)
live_effects/lpe-perspective_path.cpp \
live_effects/lpe-perspective_path.h \
live_effects/lpe-envelope.cpp \
- live_effects/lpe-envelope.h
+ live_effects/lpe-envelope.h \
+ live_effects/lpe-perp_bisector.cpp \
+ live_effects/lpe-perp_bisector.h
index 125d22c3fb563687da8a74d82de05c6f9a53092f..6ae30fe4c11f442244a443a2b8163f5b8c222842 100644 (file)
#include "live_effects/lpe-spiro.h"
#include "live_effects/lpe-constructgrid.h"
#include "live_effects/lpe-envelope.h"
+#include "live_effects/lpe-perp_bisector.h"
// end of includes
#include "nodepath.h"
{SPIRO, N_("Spiro spline"), "spiro"},
{CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"},
{ENVELOPE, N_("Envelope Deformation"), "envelope"},
+ {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
case ENVELOPE:
neweffect = static_cast<Effect*> ( new LPEEnvelope(lpeobj) );
break;
+ case PERP_BISECTOR:
+ neweffect = static_cast<Effect*> ( new LPEPerpBisector(lpeobj) );
+ break;
default:
g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
neweffect = NULL;
index 328181adcb875276934df80c173753bfe671bcd9..086b973af7c94d4c9b04cf14e810eb3230588797 100644 (file)
SPIRO,
CONSTRUCT_GRID,
ENVELOPE,
+ PERP_BISECTOR,
INVALID_LPE // This must be last
};
diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp
--- /dev/null
@@ -0,0 +1,94 @@
+#define INKSCAPE_LPE_PERP_BISECTOR_CPP
+/** \file
+ * LPE <perp_bisector> implementation.
+ */
+/*
+ * Authors:
+ * Maximilian Albert
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/lpe-perp_bisector.h"
+#include "display/curve.h"
+#include <libnr/n-art-bpath.h>
+
+#include <2geom/path.h>
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject),
+ length_left(_("Length left"), _(""), "length-left", &wr, this, 200),
+ length_right(_("Length right"), _(""), "length-right", &wr, this, 200)
+{
+ registerParameter( dynamic_cast<Parameter *>(&length_left) );
+ registerParameter( dynamic_cast<Parameter *>(&length_right) );
+}
+
+LPEPerpBisector::~LPEPerpBisector()
+{
+
+}
+
+Geom::Point LPEPerpBisector::left_end(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) {
+ Geom::Point A(pwd2_in.firstValue());
+ Geom::Point B(pwd2_in.lastValue());
+ Geom::Point M((A + B)/2);
+
+ Geom::Point dir1((B - M).ccw());
+
+ if (dir1.length() > Geom::EPSILON)
+ dir1 = Geom::unit_vector(dir1) * length_left;
+
+ return M + dir1;
+}
+
+Geom::Piecewise<Geom::D2<Geom::SBasis> >
+LPEPerpBisector::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
+{
+ using namespace Geom;
+
+ Piecewise<D2<SBasis> > output;
+
+ Point A(pwd2_in.firstValue());
+ Point B(pwd2_in.lastValue());
+ Point M((A + B)/2);
+
+ Point dir1((B - M).ccw());
+ Point dir2((A - M).ccw());
+
+ if (dir1.length() > EPSILON)
+ dir1 = unit_vector(dir1) * length_left;
+
+ if (dir2.length() > EPSILON)
+ dir2 = unit_vector(dir2) * length_right;
+
+ Point C(M + dir1);
+ Point D(M + dir2);
+
+ output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
+
+ return output;
+}
+
+/* ######################## */
+
+} //namespace LivePathEffect
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef INKSCAPE_LPE_PERP_BISECTOR_H
+#define INKSCAPE_LPE_PERP_BISECTOR_H
+
+/** \file
+ * LPE <perp_bisector> implementation, see lpe-perp_bisector.cpp.
+ */
+/*
+ * Authors:
+ * Maximilian Albert
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/effect.h"
+#include "live_effects/parameter/parameter.h"
+#include "live_effects/parameter/point.h"
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+class LPEPerpBisector : public Effect {
+public:
+ LPEPerpBisector(LivePathEffectObject *lpeobject);
+ virtual ~LPEPerpBisector();
+
+ virtual EffectType effectType () { return PERP_BISECTOR; }
+
+ virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
+ doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
+
+ Geom::Point left_end(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
+
+private:
+ ScalarParam length_left;
+ ScalarParam length_right;
+
+ LPEPerpBisector(const LPEPerpBisector&);
+ LPEPerpBisector& operator=(const LPEPerpBisector&);
+};
+
+} //namespace LivePathEffect
+} //namespace Inkscape
+
+#endif