summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-10-25 16:52:07 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-10-25 16:52:07 +0000
commitcd7e100476cf935ebbac947109012bcba2f44875 (patch)
treeda617c168ab5d4ae8f38c749fe6fa76c3471ca99 /src
parentupdate to trunk (diff)
downloadinkscape-cd7e100476cf935ebbac947109012bcba2f44875.tar.gz
inkscape-cd7e100476cf935ebbac947109012bcba2f44875.zip
Removing new roughen changes to create a new Spray branch
(bzr r14422.1.11)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-roughen.cpp91
-rw-r--r--src/live_effects/lpe-roughen.h3
2 files changed, 41 insertions, 53 deletions
diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp
index 55ca77e9c..cea91509e 100644
--- a/src/live_effects/lpe-roughen.cpp
+++ b/src/live_effects/lpe-roughen.cpp
@@ -183,15 +183,19 @@ double LPERoughen::sign(double random_number)
return random_number;
}
-Geom::Point LPERoughen::randomize(double max_lenght, bool is_node)
+Geom::Point LPERoughen::randomize(double max_lenght, double direction)
{
- double factor = 1.0/3.0;
- if(is_node){
- factor = 1.0;
- }
- double displace_x_parsed = displace_x * global_randomize * factor;
- double displace_y_parsed = displace_y * global_randomize * factor;
+ double displace_x_parsed = displace_x * global_randomize;
+ double displace_y_parsed = displace_y * global_randomize;
Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed));
+ if( direction != 0){
+ int angle = (int)max_smooth_angle;
+ if (angle == 0){
+ angle = 1;
+ }
+ double dist = Geom::distance(Geom::Point(0,0),output);
+ output = Geom::Point::polar(direction + sign(Geom::deg_to_rad(rand() % angle)), dist);
+ }
if( fixed_displacement ){
Geom::Ray ray(Geom::Point(0,0),output);
output = Geom::Point::polar(ray.angle(), max_lenght);
@@ -199,19 +203,6 @@ Geom::Point LPERoughen::randomize(double max_lenght, bool is_node)
return output;
}
-Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end)
-{
- int angle = (int)max_smooth_angle;
- if (angle == 0){
- angle = 1;
- }
- Geom::Ray ray(start, end);
- if(!fixed_displacement ){
- lenght = Geom::distance(start, end);
- }
- return Geom::Point::polar(ray.angle() + sign(Geom::deg_to_rad(rand() % angle)), lenght) + start;
-}
-
void LPERoughen::doEffect(SPCurve *curve)
{
Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector());
@@ -326,9 +317,9 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point
Geom::Point point_b2(0, 0);
Geom::Point point_b3(0, 0);
if (shift_nodes) {
- point_a3 = randomize(max_lenght, true);
+ point_a3 = randomize(max_lenght);
if(last){
- point_b3 = randomize(max_lenght, true);
+ point_b3 = randomize(max_lenght);
}
}
if (handles == HM_RAND || handles == HM_SMOOTH) {
@@ -359,55 +350,53 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point
std::pair<Geom::CubicBezier, Geom::CubicBezier> div = cubic->subdivide(t);
std::vector<Geom::Point> seg1 = div.first.controlPoints(),
seg2 = div.second.controlPoints();
- point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3);
- point_b2 = seg1[2];
- point_b3 = seg2[3] + point_b3;
- point_a3 = seg1[3] + point_a3;
Geom::Ray ray(prev,A->initialPoint());
- point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght);
+ point_a1 = Geom::Point::polar(ray.angle(), max_lenght);
if(prev == Geom::Point(0,0)){
point_a1 = randomize(max_lenght);
}
+ ray.setPoints(seg1[3] + point_a3, seg2[1] + point_a3);
+ point_b1 = randomize(max_lenght, ray.angle());
if(last){
- Geom::Path b2(point_b3);
- b2.appendNew<Geom::LineSegment>(point_a3);
- point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0));
+ ray.setPoints(seg2[3] + point_b3, A->pointAt(1 - (t / 3)) + point_b3);
+ point_b2 = randomize(max_lenght, ray.angle());
}
- ray.setPoints(point_b1, point_a3);
- point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght);
+ ray.setPoints(seg2[1] + point_a3 + point_b1, seg2[0] + point_a3);
+ point_a2 = Geom::Point::polar(ray.angle(), max_lenght);
if(last){
- prev = point_b2;
+ prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3;
} else {
- prev = point_a2;
+ prev = seg1[3] + point_a2 + point_a3;
}
out->moveto(seg1[0]);
- out->curveto(point_a1,point_a2,point_a3);
- out->curveto(point_b1, point_b2, point_b3);
+ out->curveto(seg1[0] + point_a1, seg1[3] + point_a2 + point_a3, seg1[3] + point_a3);
+ if(last){
+ out->curveto(seg2[1] + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, seg2[3] + point_b3);
+ } else {
+ out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3);
+ }
} else if(handles == HM_SMOOTH && !cubic) {
- point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)));
- point_b2 = A->pointAt(t +((t / 3) * 2));
- point_b3 = A->finalPoint() + point_b3;
- point_a3 = A->pointAt(t) + point_a3;
Geom::Ray ray(prev,A->initialPoint());
- point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght);
- if(prev == Geom::Point(0,0)){
+ point_a1 = Geom::Point::polar(ray.angle(), max_lenght);
+ if(prev==Geom::Point(0,0)){
point_a1 = randomize(max_lenght);
}
+ ray.setPoints(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3);
+ point_b1 = randomize(max_lenght, ray.angle());
if(last){
- Geom::Path b2(point_b3);
- b2.appendNew<Geom::LineSegment>(point_a3);
- point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0));
+ ray.setPoints(A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3);
+ point_b2 = randomize(max_lenght, ray.angle());
}
- ray.setPoints(point_b1, point_a3);
- point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght);
+ ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3);
+ point_a2 = Geom::Point::polar(ray.angle(), max_lenght);
if(last){
- prev = point_b2;
+ prev = A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3;
} else {
- prev = point_a2;
+ prev = A->pointAt(t) + point_a3 + point_a2;
}
out->moveto(A->initialPoint());
- out->curveto(point_a1,point_a2,point_a3);
- out->curveto(point_b1, point_b2, point_b3);
+ out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3);
+ out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3);
} else if (cubic) {
std::pair<Geom::CubicBezier, Geom::CubicBezier> div = cubic->subdivide(t);
std::vector<Geom::Point> seg1 = div.first.controlPoints(),
diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h
index 6224c09fa..e3ede2c2d 100644
--- a/src/live_effects/lpe-roughen.h
+++ b/src/live_effects/lpe-roughen.h
@@ -45,8 +45,7 @@ public:
virtual void doEffect(SPCurve *curve);
virtual double sign(double randNumber);
- virtual Geom::Point randomize(double max_lenght, bool is_node = false);
- virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end);
+ virtual Geom::Point randomize(double max_lenght, double direction = 0);
virtual void doBeforeEffect(SPLPEItem const * lpeitem);
virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last);
virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move);