summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-09-04 08:42:18 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-09-04 08:42:18 +0000
commit703f1f35c2f5499e525685df21b9faa666c31197 (patch)
tree02d5984ed89806a903743384fbbe834c91b0a094
parentUpdate Indonesian translation (diff)
downloadinkscape-703f1f35c2f5499e525685df21b9faa666c31197.tar.gz
inkscape-703f1f35c2f5499e525685df21b9faa666c31197.zip
Fix issue https://gitlab.com/inkscape/inbox/issues/816 Stroke to Path conversion wrong on dashes w/ round caps
-rw-r--r--src/splivarot.cpp108
1 files changed, 34 insertions, 74 deletions
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index 7719a7071..71920559b 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -1001,48 +1001,29 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only)
res->SetBackData(false);
if (!i_style->stroke_dasharray.values.empty()) {
- // For dashed strokes, use Stroke method, because Outline can't do dashes
- // However Stroke adds lots of extra nodes _or_ makes the path crooked, so consider this a temporary workaround
-
- orig->ConvertWithBackData(0.1);
+ double size = Geom::L2(Geom::bounds_fast(pathv)->dimensions());
+ orig->ConvertWithBackData(0.005);
orig->DashPolylineFromStyle(i_style, scale, 0);
+ orig->Simplify(size * 0.00005);
+ }
+ orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter);
- Shape* theShape = new Shape;
- orig->Stroke(theShape, false, 0.5*o_width, o_join, o_butt,
- 0.5 * o_miter);
- orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter);
-
- if (!bbox_only) {
- Shape *theRes = new Shape;
- theRes->ConvertToShape(theShape, fill_positive);
-
- Path *originaux[1];
- originaux[0] = res;
- theRes->ConvertToForme(orig, 1, originaux);
- res->Coalesce(5.0);
- delete theRes;
- }
- delete theShape;
- } else {
- orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter);
-
- if (!bbox_only) {
- orig->Coalesce(0.5 * o_width);
- Shape *theShape = new Shape;
- Shape *theRes = new Shape;
+ if (!bbox_only) {
+ orig->Coalesce(0.5 * o_width);
+ Shape *theShape = new Shape;
+ Shape *theRes = new Shape;
- res->ConvertWithBackData(1.0);
- res->Fill(theShape, 0);
- theRes->ConvertToShape(theShape, fill_positive);
+ res->ConvertWithBackData(1.0);
+ res->Fill(theShape, 0);
+ theRes->ConvertToShape(theShape, fill_positive);
- Path *originaux[1];
- originaux[0] = res;
- theRes->ConvertToForme(orig, 1, originaux);
+ Path *originaux[1];
+ originaux[0] = res;
+ theRes->ConvertToForme(orig, 1, originaux);
- delete theShape;
- delete theRes;
- }
+ delete theShape;
+ delete theRes;
}
if (orig->descr_cmd.size() <= 1) {
@@ -1292,54 +1273,33 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy)
}
+
orig->LoadPathVector(pathv);
res->SetBackData(false);
if (!i_style->stroke_dasharray.values.empty()) {
- // For dashed strokes, use Stroke method, because Outline can't do dashes
- // However Stroke adds lots of extra nodes _or_ makes the path crooked, so consider this a temporary workaround
-
- orig->ConvertWithBackData(0.1);
+ double size = Geom::L2(Geom::bounds_fast(pathv)->dimensions());
+ orig->ConvertWithBackData(0.005);
orig->DashPolylineFromStyle(i_style, scale, 0);
+ orig->Simplify(size * 0.00005);
+ }
+ orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter);
+ orig->Coalesce(0.5 * o_width);
- Shape* theShape = new Shape;
- orig->Stroke(theShape, false, 0.5*o_width, o_join, o_butt,
- 0.5 * o_miter);
- orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter);
-
- Shape *theRes = new Shape;
-
- theRes->ConvertToShape(theShape, fill_positive);
-
- Path *originaux[1];
- originaux[0] = res;
- theRes->ConvertToForme(orig, 1, originaux);
-
- res->Coalesce(5.0);
-
- delete theShape;
- delete theRes;
-
- } else {
- orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter);
-
- orig->Coalesce(0.5 * o_width);
-
- Shape *theShape = new Shape;
- Shape *theRes = new Shape;
+ Shape *theShape = new Shape;
+ Shape *theRes = new Shape;
- res->ConvertWithBackData(1.0);
- res->Fill(theShape, 0);
- theRes->ConvertToShape(theShape, fill_positive);
+ res->ConvertWithBackData(1.0);
+ res->Fill(theShape, 0);
+ theRes->ConvertToShape(theShape, fill_positive);
- Path *originaux[1];
- originaux[0] = res;
- theRes->ConvertToForme(orig, 1, originaux);
+ Path *originaux[1];
+ originaux[0] = res;
+ theRes->ConvertToForme(orig, 1, originaux);
- delete theShape;
- delete theRes;
- }
+ delete theShape;
+ delete theRes;
if (orig->descr_cmd.size() <= 1) {
// ca a merdĀŽ, ou bien le resultat est vide