diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-10-19 23:06:16 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-10-19 23:06:16 +0000 |
| commit | ccdb4ca4cc4aa57445c770c8410d68f777cf6ba2 (patch) | |
| tree | e72b720eb5b56a2a9a8d75f35f01bf2122717e66 /src | |
| parent | fixing roughen (diff) | |
| download | inkscape-ccdb4ca4cc4aa57445c770c8410d68f777cf6ba2.tar.gz inkscape-ccdb4ca4cc4aa57445c770c8410d68f777cf6ba2.zip | |
working 2 ways
(bzr r14422.1.2)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-roughen.cpp | 34 | ||||
| -rw-r--r-- | src/ui/tools/spray-tool.cpp | 41 |
2 files changed, 61 insertions, 14 deletions
diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 44f9c6be5..55ca77e9c 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -359,18 +359,19 @@ 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; - point_b1 = randomize(max_lenght, point_a3, seg2[1]); - point_b2 = seg1[2] + point_b2; 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 = randomize(max_lenght); } if(last){ - ray.setPoints(point_b3, point_a3); - point_b2 = randomize(max_lenght, point_b3, ray.pointAt(100.0/3.0)); + 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(point_b1, point_a3); point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); @@ -383,25 +384,30 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point out->curveto(point_a1,point_a2,point_a3); out->curveto(point_b1, point_b2, 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 = Geom::Point::polar(ray.angle(), max_lenght); - if(prev==Geom::Point(0,0)){ + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); if(last){ - point_b2 = randomize(max_lenght, A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); + 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->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); - point_a2 = Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3; + prev = point_b2; } else { - prev = A->pointAt(t) + point_a3 + point_a2; + prev = point_a2; } out->moveto(A->initialPoint()); - 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); + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, 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/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index e2be5ca4b..240d002ae 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -380,6 +380,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, Inkscape::XML::Node *old_repr = item->getRepr(); Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); + copy->setAttribute("inkscape:spray-origin", item->getId()); parent->appendChild(copy); SPObject *new_obj = doc->getObjectByRepr(copy); @@ -393,6 +394,46 @@ static bool sp_spray_recursive(SPDesktop *desktop, Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); did = true; + Geom::OptRect bbox = item_copied->desktopGeometricBounds(); + std::vector<SPItem*> items = desktop->getDocument()->getItemsInBox(desktop->dkey, *bbox); + for (std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); i++) { + SPItem *item_down = *i; + std::cout << item_down->getAttribute("inkscape:spray-origin") << "asdgfasdasas\n"; + if(item_down->getAttribute("inkscape:spray-origin") &&( strcmp(item_down->getAttribute("inkscape:spray-origin"),item->getId()) == 0 || strcmp(item_down->getId(),item->getId()) == 0)){ + if(!SP_IS_GROUP(item)){ + SPShape *down_item_shape = dynamic_cast<SPShape *>(item_down); + if (down_item_shape) { + Geom::PathVector c; + SPPath *down_item_path = dynamic_cast<SPPath *>(down_item_shape); + if (down_item_path) { + c = down_item_path->get_curve()->get_pathvector(); + } else { + c = down_item_shape->getCurve()->get_pathvector(); + } + if (c) { + SPShape *copied_item_shape = dynamic_cast<SPShape *>(item_copied); + if (copied_item_shape) { + Geom::PathVector d; + SPPath *copied_item_path = dynamic_cast<SPPath *>(copied_item_shape); + if (copied_item_path) { + d = copied_item_path->get_curve()->get_pathvector(); + } else { + d = copied_item_shape->getCurve()->get_pathvector(); + } + if (d) { + Geom::CrossingSet cs = Geom::crossings(c,d); + if(cs[0].size() == 0){ + continue; + } + } + } + } + } + item_copied->deleteObject(); + std::cout << item_down->getAttribute("inkscape:spray-origin") << "hasssss\n"; + did = false; + } + } } } #ifdef ENABLE_SPRAY_MODE_SINGLE_PATH |
