1 /** @file
2 * @brief LPE effect that draws a circle based on two points and a radius
3 * - implementation
4 */
5 /* Authors:
6 * Johan Engelen <j.b.c.engelen@utwente.nl>
7 *
8 * Copyright (C) 2007 Authors
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
13 #include "live_effects/lpe-circle_with_radius.h"
14 #include "display/curve.h"
16 // You might need to include other 2geom files. You can add them here:
17 #include <2geom/path.h>
18 #include <2geom/sbasis.h>
19 #include <2geom/bezier-to-sbasis.h>
20 #include <2geom/d2.h>
22 using namespace Geom;
24 namespace Inkscape {
25 namespace LivePathEffect {
27 LPECircleWithRadius::LPECircleWithRadius(LivePathEffectObject *lpeobject) :
28 Effect(lpeobject)//,
29 // initialise your parameters here:
30 //radius(_("Float parameter"), _("just a real number like 1.4!"), "svgname", &wr, this, 50)
31 {
32 // register all your parameters here, so Inkscape knows which parameters this effect has:
33 //registerParameter( dynamic_cast<Parameter *>(&radius) );
34 }
36 LPECircleWithRadius::~LPECircleWithRadius()
37 {
39 }
41 void _circle(Geom::Point center, double radius, std::vector<Geom::Path> &path_out) {
42 Geom::Path pb;
44 D2<SBasis> B;
45 Linear bo = Linear(0, 2 * M_PI);
47 B[0] = cos(bo,4);
48 B[1] = sin(bo,4);
50 B = B * radius + center;
52 pb.append(SBasisCurve(B));
54 path_out.push_back(pb);
55 }
57 std::vector<Geom::Path>
58 LPECircleWithRadius::doEffect_path (std::vector<Geom::Path> const & path_in)
59 {
60 std::vector<Geom::Path> path_out = std::vector<Geom::Path>();
62 Geom::Point center = path_in[0].initialPoint();
63 Geom::Point pt = path_in[0].finalPoint();
65 double radius = Geom::L2(pt - center);
67 _circle(center, radius, path_out);
69 return path_out;
70 }
72 /*
74 Geom::Piecewise<Geom::D2<Geom::SBasis> >
75 LPECircleWithRadius::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in)
76 {
77 Geom::Piecewise<Geom::D2<Geom::SBasis> > output;
79 output = pwd2_in; // spice this up to make the effect actually *do* something!
81 return output;
82 }
84 */
86 /* ######################## */
88 } //namespace LivePathEffect
89 } /* namespace Inkscape */
91 /*
92 Local Variables:
93 mode:c++
94 c-file-style:"stroustrup"
95 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
96 indent-tabs-mode:nil
97 fill-column:99
98 End:
99 */
100 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :