12#include <glibmm/i18n.h>
17namespace LivePathEffect {
48 nbgenerations(_(
"N_r of generations:"), _(
"Depth of the recursion --- keep low!!"),
"nbgenerations", &wr, this, 1),
49 generator(_(
"Generating path:"), _(
"Path whose segments define the iterated transforms"),
"generator", &wr, this,
"M0,0 L30,0 M0,10 L10,10 M 20,10 L30,10"),
50 similar_only(_(
"_Use uniform transforms only"), _(
"2 consecutive segments are used to reverse/preserve orientation only (otherwise, they define a general transform)."),
"similar_only", &wr, this, false),
51 drawall(_(
"Dra_w all generations"), _(
"If unchecked, draw only the last generation"),
"drawall", &wr, this, true),
53 ref_path(_(
"Reference segment:"), _(
"The reference segment. Defaults to the horizontal midline of the bbox."),
"ref_path", &wr, this,
"M0,0 L10,0"),
57 maxComplexity(_(
"_Max complexity:"), _(
"Disable effect if the output is too complex"),
"maxComplexity", &wr, this, 1000)
97 if (generating_path.
empty()) {
120 std::vector<Affine> transforms;
121 for (
const auto & i : generating_path){
124 Point p = i.pointAt(0);
125 Point u = i.pointAt(1)-p;
128 transforms.push_back(m);
129 }
else if(i.size()>=2){
130 Point p = i.pointAt(1);
131 Point u = i.pointAt(2)-p;
132 Point v = p-i.pointAt(0);
134 int sign = (u[
X]*v[
Y]-u[
Y]*v[
X]>=0?1:-1);
140 transforms.push_back(m);
144 if (transforms.empty()){
149 int path_in_complexity = 0;
150 for (
const auto & k : path_in){
151 path_in_complexity+=k.
size();
153 double complexity = std::pow(transforms.size(),
nbgenerations) * path_in_complexity;
155 int k = transforms.size();
157 complexity = (std::pow(k,
nbgenerations+1)-1)/(k-1)*path_in_complexity;
163 g_warning(
"VonKoch lpe's output too complex. Effect bypassed.");
174 complexity = path_in_complexity;
179 for (
const auto & transform : transforms){
182 complexity+=pathi[k].
size();
260 using namespace Geom;
272 A =
paths.front().pointAt(0);
273 B =
paths.front().pointAt(
paths.front().size());
275 if (
paths.size()!=1||
paths.front().size()!=1){
290 using namespace Geom;
3x3 matrix representing an affine transformation.
Affine inverse() const
Compute the inverse matrix.
constexpr C extent() const
constexpr C middle() const
size_type size() const
Get the number of paths in the vector.
void push_back(Path const &path)
Append a path at the end.
bool empty() const
Check whether the vector contains any paths.
Sequence of contiguous curves, aka spline.
Point pointAt(Coord t) const
Get the point at the specified time value.
size_type size() const
Natural size of the path.
void appendNew(Args &&... args)
Append a new curve to the path.
Two-dimensional point that doubles as a vector.
void registerParameter(Parameter *param)
virtual void resetDefaults(SPItem const *item)
Sets all parameters to their default values and writes them to SVG.
bool apply_to_clippath_and_mask
void original_bbox(SPLPEItem const *lpeitem, bool absolute=false, bool clip_mask=false, Geom::Affine base_transform=Geom::identity())
Geom::Interval boundingbox_Y
Geom::Interval boundingbox_X
LPEVonKoch(LivePathEffectObject *lpeobject)
bool doOnOpen(SPLPEItem const *lpeitem) override
Is performed on load document or revert If the item is fixed legacy return true.
ScalarParam nbgenerations
VonKochRefPathParam ref_path
ScalarParam maxComplexity
Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override
void doBeforeEffect(SPLPEItem const *item) override
Is performed each time before the effect is updated.
VonKochPathParam generator
void resetDefaults(SPItem const *item) override
Sets all parameters to their default values and writes them to SVG.
Geom::PathVector const & get_pathvector() const
bool param_readSVGValue(const gchar *strvalue) override
void set_new_value(Geom::PathVector const &newpath, bool write_to_svg)
void param_setup_nodepath(Inkscape::NodePath::Path *np) override
Geom::PathVector _pathvector
Geom::Affine get_relative_affine()
void param_set_range(double min, double max)
void param_make_integer(bool yes=true)
void param_setup_nodepath(Inkscape::NodePath::Path *np) override
bool param_readSVGValue(const gchar *strvalue) override
void param_setup_nodepath(Inkscape::NodePath::Path *np) override
Base class for visual SVG elements.
vector< vector< Point > > paths
Various utility functions.
static float sign(double number)
Returns +1 for positive numbers, -1 for negative numbers, and 0 otherwise.
Helper class to stream background task notifications as a series of messages.
Base class for live path effect items.