Code

Commit LivePathEffect branch to trunk!
[inkscape.git] / src / live_effects / lpe-slant.cpp
1 #define INKSCAPE_LPE_SLANT_CPP\r
2 \r
3 /*\r
4  * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
5  *\r
6  * Released under GNU GPL, read the file 'COPYING' for more information\r
7  */\r
8 \r
9 #include "live_effects/lpe-slant.h"\r
10 #include "sp-shape.h"\r
11 #include "display/curve.h"\r
12 #include <libnr/n-art-bpath.h>\r
13 #include "live_effects/n-art-bpath-2geom.h"\r
14 \r
15 #include <2geom/path.h>\r
16 #include <2geom/transforms.h>\r
17 \r
18 #include "svg/svg.h"\r
19 \r
20 namespace Inkscape {\r
21 namespace LivePathEffect {\r
22 \r
23 LPESlant::LPESlant(LivePathEffectObject *lpeobject) :\r
24     Effect(lpeobject),\r
25     factor(_("Slant factor"), _("y = y + x*(slant factor)"), "factor", &wr, this),\r
26     center(_("Center"), _("The x-coord of this point is around which the slant will happen"), "center", &wr, this)\r
27 {\r
28     registerParameter( dynamic_cast<Parameter *>(&factor) );\r
29     registerParameter( dynamic_cast<Parameter *>(&center) );\r
30 }\r
31 \r
32 LPESlant::~LPESlant()\r
33 {\r
34 }\r
35 \r
36 void\r
37 LPESlant::doEffect(SPCurve * curve)\r
38 {\r
39     NArtBpath *bpath = curve->_bpath;\r
40     int i = 0;\r
41     while(bpath[i].code != NR_END) {\r
42         bpath[i].y1 += (bpath[i].x1-center[Geom::X]) * factor;\r
43         bpath[i].y2 += (bpath[i].x2-center[Geom::X]) * factor;\r
44         bpath[i].y3 += (bpath[i].x3-center[Geom::X]) * factor;\r
45         i++;\r
46     }\r
47 \r
48 }\r
49 \r
50 }; //namespace LivePathEffect\r
51 }; /* namespace Inkscape */\r
52 \r
53 /*\r
54   Local Variables:\r
55   mode:c++\r
56   c-file-style:"stroustrup"\r
57   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
58   indent-tabs-mode:nil\r
59   fill-column:99\r
60   End:\r
61 */\r
62 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r