Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
lpe-interpolate_points.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/*
7 * Authors:
8 * Johan Engelen
9 *
10 * Copyright (C) Johan Engelen 2014 <j.b.c.engelen@alumnus.utwente.nl>
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
17// TODO due to internal breakage in glibmm headers, this must be last:
18#include <glibmm/i18n.h>
19
20namespace Inkscape {
21namespace LivePathEffect {
22
23
25 {Geom::Interpolate::INTERP_LINEAR , N_("Linear"), "Linear"},
26 {Geom::Interpolate::INTERP_CUBICBEZIER , N_("CubicBezierFit"), "CubicBezierFit"},
27 {Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN , N_("CubicBezierJohan"), "CubicBezierJohan"},
28 {Geom::Interpolate::INTERP_SPIRO , N_("SpiroInterpolator"), "SpiroInterpolator"},
29 {Geom::Interpolate::INTERP_CENTRIPETAL_CATMULLROM, N_("Centripetal Catmull-Rom"), "CentripetalCatmullRom"}
30};
32
34 : Effect(lpeobject)
35 , interpolator_type(
36 _("Interpolator type:"),
37 _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"),
38 "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CENTRIPETAL_CATMULLROM)
39{
40 show_orig_path = false;
41
43}
44
46
49{
50 Geom::PathVector path_out;
51 std::unique_ptr<Geom::Interpolate::Interpolator> interpolator( Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value())) );
52
53 for(const auto & path_it : path_in) {
54 if (path_it.empty())
55 continue;
56
57 if (path_it.closed()) {
58 g_warning("Interpolate points LPE currently ignores whether path is closed or not.");
59 }
60
61 std::vector<Geom::Point> pts;
62 pts.push_back(path_it.initialPoint());
63
64 for (Geom::Path::const_iterator it = path_it.begin(), e = path_it.end_default(); it != e; ++it) {
65 pts.push_back((*it).finalPoint());
66 }
67
68 Geom::Path path = interpolator->interpolateToPath(pts);
69
70 path_out.push_back(path);
71 }
72
73 return path_out;
74}
75
76
77} //namespace LivePathEffect
78} /* namespace Inkscape */
79
80/*
81 Local Variables:
82 mode:c++
83 c-file-style:"stroustrup"
84 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
85 indent-tabs-mode:nil
86 fill-column:99
87 End:
88*/
89// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
static Interpolator * create(InterpolatorType type)
Sequence of subpaths.
Definition pathvector.h:122
void push_back(Path const &path)
Append a path at the end.
Definition pathvector.h:172
Sequence of contiguous curves, aka spline.
Definition path.h:353
void registerParameter(Parameter *param)
Definition effect.cpp:1704
Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:42
LPE interpolate_points implementation, see lpe-interpolate_points.cpp.
Interpolators for lists of points.
Various utility functions.
Definition affine.h:22
static const Util::EnumData< unsigned > InterpolatorTypeData[]
static const Util::EnumDataConverter< unsigned > InterpolatorTypeConverter(InterpolatorTypeData, sizeof(InterpolatorTypeData)/sizeof(*InterpolatorTypeData))
Helper class to stream background task notifications as a series of messages.
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:27