diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2011-09-24 15:10:38 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2011-09-24 15:10:38 +0000 |
| commit | d9d71d4545ee9ebadfe54ccb1f69fd54e4b27f56 (patch) | |
| tree | bbc8ed74dea5ad4164b8bb06991a509452085aec /src | |
| parent | restructure powerstroke LPE a bit in preparation for cusp fixup (diff) | |
| download | inkscape-d9d71d4545ee9ebadfe54ccb1f69fd54e4b27f56.tar.gz inkscape-d9d71d4545ee9ebadfe54ccb1f69fd54e4b27f56.zip | |
powerstroke: add bevel cusp. but it bugs closed paths. need to restructure...
(bzr r10646)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-powerstroke.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 8884e8b21..ca952785c 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -579,35 +579,28 @@ LPEPowerStroke::path_from_piecewise_fix_cusps(Geom::Piecewise<Geom::D2<Geom::SBa /* per definition, the input piecewise should be closed. each discontinuity should be fixed with a cusp-ending, as defined by cusp_linecap_type */ + LineCuspType cusp_linecap = static_cast<LineCuspType>(cusp_linecap_type.get_value()); + Geom::PathBuilder pb; if(B.size() == 0) return pb.peek(); Geom::Point start = B[0].at0(); pb.moveTo(start); - for(unsigned i = 0; ; i++) { - if ( (i+1 == B.size()) - || !are_near(B[i+1].at0(), B[i].at1(), tol) ) - { - //start of a new path - if (are_near(start, B[i].at1()) && sbasis_size(B[i]) <= 1) { - pb.closePath(); - //last line seg already there (because of .closePath()) - goto no_add; - } - build_from_sbasis(pb, B[i], tol, false); - if (are_near(start, B[i].at1())) { - //it's closed, the last closing segment was not a straight line so it needed to be added, but still make it closed here with degenerate straight line. - pb.closePath(); - } - no_add: - if (i+1 >= B.size()) { + build_from_sbasis(pb, B[0], tol, false); + for (unsigned i=1; i < B.size(); i++) { + if (!are_near(B[i-1].at1(), B[i].at0(), tol) ) + { // discontinuity found, so fix it :-) + switch (cusp_linecap) { + LINECUSP_ROUND: + LINECUSP_SHARP: + LINECUSP_BEVEL: + default: + pb.lineTo(B[i].at0()); break; } - start = B[i+1].at0(); - pb.moveTo(start); - } else { - build_from_sbasis(pb, B[i], tol, false); } + build_from_sbasis(pb, B[i], tol, false); } + pb.closePath(); pb.finish(); return pb.peek(); } |
