X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flive_effects%2Flpe-rough-hatches.cpp;h=228857ebf86f99cfe63ef229b2075c97882fcd87;hb=cc618cb0faf84b6f5ab2cc9802b29d03f6a22f97;hp=bcfd0f3736d845bc544f928169d9429e06b65fe7;hpb=fa06265a287f5ed59b9a268ed9d1f41d29dc251e;p=inkscape.git diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index bcfd0f373..228857ebf 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -94,7 +94,7 @@ public: LevelsCrossings(std::vector > const ×, Piecewise > const &f, Piecewise const &dx){ - + for (unsigned i=0; i > +Geom::Piecewise > LPERoughHatches::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in){ //std::cout<<"doEffect_pwd2:\n"; Piecewise > result; - + Piecewise > transformed_pwd2_in = pwd2_in; Point start = pwd2_in.segs.front().at0(); Point end = pwd2_in.segs.back().at1(); @@ -324,11 +324,11 @@ LPERoughHatches::doEffect_pwd2 (Geom::Piecewise > const & Matrix mat(-hatches_dir[Y], hatches_dir[X], hatches_dir[X], hatches_dir[Y],0,0); transformed_pwd2_in = transformed_pwd2_in * mat; transformed_org *= mat; - + std::vector > snakePoints; snakePoints = linearSnake(transformed_pwd2_in, transformed_org); if ( snakePoints.size() > 0 ){ - Piecewise >smthSnake = smoothSnake(snakePoints); + Piecewise >smthSnake = smoothSnake(snakePoints); smthSnake = smthSnake*mat.inverse(); if (do_bend.get_value()){ smthSnake = smthSnake*bend_mat; @@ -354,7 +354,7 @@ LPERoughHatches::generateLevels(Interval const &domain, double x_org){ while (x < domain.max()){ result.push_back(x); double rdm = 1; - if (dist_rdm.get_value() != 0) + if (dist_rdm.get_value() != 0) rdm = 1.+ double((2*dist_rdm - dist_rdm.get_value()))/100.; x+= step*rdm; step*=scale;//(1.+double(growth)); @@ -366,7 +366,7 @@ LPERoughHatches::generateLevels(Interval const &domain, double x_org){ //------------------------------------------------------- // Walk through the intersections to create linear hatches //------------------------------------------------------- -std::vector > +std::vector > LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ //std::cout<<"linearSnake:\n"; @@ -401,14 +401,14 @@ LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ unsigned i,j; lscs.findFirstUnused(i,j); - + std::vector result_component; int n = int((range->min()-org[X])/hatch_dist); - - while ( i < lscs.size() ){ + + while ( i < lscs.size() ){ int dir = 0; //switch orientation of first segment according to starting point. - if (i % 2 == n%2 && j < lscs[i].size()-1 && !lscs[i][j].used){ + if ((i % 2 == n % 2) && ((j + 1) < lscs[i].size()) && !lscs[i][j].used){ j += 1; dir = 2; } @@ -428,7 +428,7 @@ LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ //------------------------------------------------------- // Smooth the linear hatches according to params... //------------------------------------------------------- -Piecewise > +Piecewise > LPERoughHatches::smoothSnake(std::vector > const &linearSnake){ Piecewise > result; @@ -444,7 +444,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake Geom::Path res_comp_top(last_pt); Geom::Path res_comp_bot(last_pt); unsigned i=1; - //bool is_top = true;//Inversion here; due to downward y? + //bool is_top = true;//Inversion here; due to downward y? bool is_top = ( linearSnake[comp][0][Y] < linearSnake[comp][1][Y] ); while( i+1 > const &linearSnake double scale_in = (is_top ? scale_tf : scale_bf ); double scale_out = (is_top ? scale_tb : scale_bb ); if (is_top){ - if (top_edge_variation.get_value() != 0) + if (top_edge_variation.get_value() != 0) new_pt[Y] += double(top_edge_variation)-top_edge_variation.get_value()/2.; - if (top_tgt_variation.get_value() != 0) + if (top_tgt_variation.get_value() != 0) new_pt[X] += double(top_tgt_variation)-top_tgt_variation.get_value()/2.; if (top_smth_variation.get_value() != 0) { scale_in*=(100.-double(top_smth_variation))/100.; scale_out*=(100.-double(top_smth_variation))/100.; } }else{ - if (bot_edge_variation.get_value() != 0) + if (bot_edge_variation.get_value() != 0) new_pt[Y] += double(bot_edge_variation)-bot_edge_variation.get_value()/2.; - if (bot_tgt_variation.get_value() != 0) + if (bot_tgt_variation.get_value() != 0) new_pt[X] += double(bot_tgt_variation)-bot_tgt_variation.get_value()/2.; if (bot_smth_variation.get_value() != 0) { scale_in*=(100.-double(bot_smth_variation))/100.; @@ -474,7 +474,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake } Point new_hdle_in = new_pt + (pt0-pt1) * (scale_in /2.); Point new_hdle_out = new_pt - (pt0-pt1) * (scale_out/2.); - + if ( fat_output.get_value() ){ //double scaled_width = double((is_top ? stroke_width_top : stroke_width_bot))/(pt1[X]-pt0[X]); double scaled_width = 1./(pt1[X]-pt0[X]); @@ -494,7 +494,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake //TODO: find a good way to handle limit cases (small smthness, large stroke). //if (inside_hdle_in[X] > inside[X]) inside_hdle_in = inside; //if (inside_hdle_out[X] < inside[X]) inside_hdle_out = inside; - + if (is_top){ res_comp_top.appendNew(last_top_hdle,new_hdle_in,new_pt); res_comp_bot.appendNew(last_bot_hdle,inside_hdle_in,inside); @@ -509,7 +509,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake }else{ res_comp.appendNew(last_hdle,new_hdle_in,new_pt); } - + last_hdle = new_hdle_out; i+=2; is_top = !is_top; @@ -525,7 +525,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake if ( fat_output.get_value() ){ res_comp = res_comp_bot; res_comp.append(res_comp_top.reverse(),Geom::Path::STITCH_DISCONTINUOUS); - } + } result.concat(res_comp.toPwSb()); } }