1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** @file
3  * @brief Roughen LPE effect, see lpe-roughen.cpp.
4  */
5 /* Authors:
6  *   Jabier Arraiza Cenoz <jabier.arraiza@marker.es>
7  *
8  * Copyright (C) 2014 Authors
9  *
10  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11  */
12 
13 #ifndef INKSCAPE_LPE_ROUGHEN_H
14 #define INKSCAPE_LPE_ROUGHEN_H
15 
16 #include "live_effects/effect.h"
17 #include "live_effects/parameter/enum.h"
18 #include "live_effects/parameter/parameter.h"
19 #include "live_effects/parameter/path.h"
20 #include "live_effects/parameter/bool.h"
21 #include "live_effects/parameter/random.h"
22 
23 #include <memory>
24 
25 namespace Inkscape {
26 namespace LivePathEffect {
27 
28 enum DivisionMethod {
29     DM_SEGMENTS,
30     DM_SIZE,
31     DM_END
32 };
33 
34 enum HandlesMethod {
35     HM_ALONG_NODES,
36     HM_RAND,
37     HM_RETRACT,
38     HM_SMOOTH,
39     HM_END
40 };
41 
42 
43 class LPERoughen : public Effect {
44 
45 public:
46     LPERoughen(LivePathEffectObject *lpeobject);
47     ~LPERoughen() override;
48 
49     void doOnApply(SPLPEItem const *lpeitem) override;
50     void doEffect(SPCurve *curve) override;
51     virtual double sign(double randNumber);
52     virtual Geom::Point randomize(double max_length, bool is_node = false);
53     void doBeforeEffect(SPLPEItem const * lpeitem) override;
54     virtual Geom::Point tPoint(Geom::Point A, Geom::Point B, double t = 0.5);
55     Gtk::Widget *newWidget() override;
56 
57 private:
58     std::unique_ptr<SPCurve> addNodesAndJitter(Geom::Curve const *A, Geom::Point &prev, Geom::Point &last_move,
59                                                double t, bool last);
60     std::unique_ptr<SPCurve> jitter(Geom::Curve const *A, Geom::Point &prev, Geom::Point &last_move);
61 
62     EnumParam<DivisionMethod> method;
63     ScalarParam max_segment_size;
64     ScalarParam segments;
65     RandomParam displace_x;
66     RandomParam displace_y;
67     RandomParam global_randomize;
68     EnumParam<HandlesMethod> handles;
69     BoolParam shift_nodes;
70     BoolParam fixed_displacement;
71     BoolParam spray_tool_friendly;
72     long seed;
73     LPERoughen(const LPERoughen &) = delete;
74     LPERoughen &operator=(const LPERoughen &) = delete;
75 
76 };
77 
78 }; //namespace LivePathEffect
79 }; //namespace Inkscape
80 #endif
81