/*
* Copyright (C) Steren Giannini 2008 <steren.giannini@gmail.com>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-envelope.h"
#include "sp-shape.h"
#include "sp-item.h"
#include "sp-path.h"
#include "sp-item-group.h"
#include <algorithm>
namespace Inkscape {
namespace LivePathEffect {
bend_path1(_("Top bend path:"), _("Top path along which to bend the original path"), "bendpath1", &wr, this, "M0,0 L1,0"),
bend_path2(_("Right bend path:"), _("Right path along which to bend the original path"), "bendpath2", &wr, this, "M0,0 L1,0"),
bend_path3(_("Bottom bend path:"), _("Bottom path along which to bend the original path"), "bendpath3", &wr, this, "M0,0 L1,0"),
bend_path4(_("Left bend path:"), _("Left path along which to bend the original path"), "bendpath4", &wr, this, "M0,0 L1,0"),
xx(_("_Enable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true),
yy(_("_Enable top & bottom paths"), _("Enable the top and bottom deformation paths"), "yy", &wr, this, true)
{
concatenate_before_pwd2 = true;
apply_to_clippath_and_mask = true;
}
{
}
void
{
// get the item bounding box
}
{
{
return pwd2_in;
}
using namespace Geom;
// Don't allow empty path parameters:
{
return pwd2_in;
}
/*
The code below is inspired from the Bend Path code developed by jfb and mgsloan
Please, read it before tring to understand this one
*/
/*The *1.001 is a hack to avoid a small bug : path at x=0 and y=0 don't work well. */
/*Scaling to the Bend Path length*/
if (scaling1 != 1.0) {
}
if (scaling2 != 1.0) {
}
if (scaling3 != 1.0) {
}
if (scaling4 != 1.0) {
}
xbis *= -1.0;
ybis *= -1.0;
/* This is important : y + ybis = constant and x +xbis = constant */
/*
output_y : Deformation by Up and Down Bend Paths
We use weighting : The closer a point is to a Band Path, the more it will be affected by this Bend Path.
This is done by the line "ybis*Derformation1 + y*Deformation2"
The result is a mix between the 2 deformed paths
*/
{
return output_y;
}
/*output_x : Deformation by Left and Right Bend Paths*/
{
return output_x;
}
/*output : Deformation by Up, Left, Right and Down Bend Paths*/
{
xsqrbis *= -1;
ysqrbis *= -1;
/*This is important : xsqr + xsqrbis = constant*/
/*
Here we mix the last two results : output_x and output_y
output1 : The more a point is close to Up and Down, the less it will be affected by output_x.
(This is done with the polynomial function)
output2 : The more a point is close to Left and Right, the less it will be affected by output_y.
output : we do the mean between output1 and output2 for all points.
*/
output /= 2.;
return output;
/*Of course, the result is not perfect, but on a graphical point of view, this is sufficent.*/
}
// do nothing when xx and yy are both false
return pwd2_in;
}
void
{
}
} // namespace LivePathEffect
} /* namespace Inkscape */