Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / live_effects / lpe-circle_with_radius.cpp
1 #define INKSCAPE_LPE_CIRCLE_WITH_RADIUS_CPP
2 /** \file
3  * LPE <circle_with_radius> implementation, used as an example for a base starting class
4  * when implementing new LivePathEffects.
5  *
6  * In vi, three global search-and-replaces will let you rename everything
7  * in this and the .h file:
8  *
9  *   :%s/CIRCLE_WITH_RADIUS/YOURNAME/g
10  *   :%s/CircleWithRadius/Yourname/g
11  *   :%s/circle_with_radius/yourname/g
12  */
13 /*
14  * Authors:
15  *   Johan Engelen
16 *
17 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
18  *
19  * Released under GNU GPL, read the file 'COPYING' for more information
20  */
22 #include "live_effects/lpe-circle_with_radius.h"
23 #include "display/curve.h"
24 #include <libnr/n-art-bpath.h>
26 // You might need to include other 2geom files. You can add them here:
27 #include <2geom/path.h>
28 #include <2geom/sbasis.h>
29 #include <2geom/bezier-to-sbasis.h>
30 #include <2geom/d2.h>
32 using namespace Geom;
34 namespace Inkscape {
35 namespace LivePathEffect {
37 LPECircleWithRadius::LPECircleWithRadius(LivePathEffectObject *lpeobject) :
38     Effect(lpeobject)//,
39     // initialise your parameters here:
40     //radius(_("Float parameter"), _("just a real number like 1.4!"), "svgname", &wr, this, 50)
41 {
42     // register all your parameters here, so Inkscape knows which parameters this effect has:
43     //registerParameter( dynamic_cast<Parameter *>(&radius) );
44 }
46 LPECircleWithRadius::~LPECircleWithRadius()
47 {
49 }
51 void _circle(Geom::Point center, double radius, std::vector<Geom::Path> &path_out) {
52     Geom::Path pb;
54     D2<SBasis> B;
55     Linear bo = Linear(0, 2 * M_PI);
57     B[0] = cos(bo,4);
58     B[1] = sin(bo,4);
60     B = B * radius + center;
62     pb.append(SBasisCurve(B));
64     path_out.push_back(pb);
65 }
67 std::vector<Geom::Path>
68 LPECircleWithRadius::doEffect_path (std::vector<Geom::Path> const & path_in)
69 {
70     std::vector<Geom::Path> path_out = std::vector<Geom::Path>();
72     Geom::Point center = path_in[0].initialPoint();
73     Geom::Point pt = path_in[0].finalPoint();
75     double radius = Geom::L2(pt - center);
77     _circle(center, radius, path_out);
79     return path_out;
80 }
82 /*
84 Geom::Piecewise<Geom::D2<Geom::SBasis> >
85 LPECircleWithRadius::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in)
86 {
87     Geom::Piecewise<Geom::D2<Geom::SBasis> > output;
89     output = pwd2_in;   // spice this up to make the effect actually *do* something!
91     return output;
92 }
94 */
96 /* ######################## */
98 } //namespace LivePathEffect
99 } /* namespace Inkscape */
101 /*
102   Local Variables:
103   mode:c++
104   c-file-style:"stroustrup"
105   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
106   indent-tabs-mode:nil
107   fill-column:99
108   End:
109 */
110 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :