mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Boolean: Avoid winding edge cases
Stay clear from testing winding on actual segments. Closes #1619
This commit is contained in:
parent
14ce1dc011
commit
192437dbe2
2 changed files with 24 additions and 1 deletions
|
@ -751,7 +751,8 @@ PathItem.inject(new function() {
|
|||
// the best quality.
|
||||
var offsets = [0.5, 0.25, 0.75],
|
||||
winding = { winding: 0, quality: -1 },
|
||||
tMin = /*#=*/Numerical.CURVETIME_EPSILON,
|
||||
// Don't go too close to segments, to avoid special winding cases:
|
||||
tMin = 1e-3,
|
||||
tMax = 1 - tMin;
|
||||
for (var i = 0; i < offsets.length && winding.quality < 0.5; i++) {
|
||||
var length = totalLength * offsets[i];
|
||||
|
|
|
@ -1230,3 +1230,25 @@ test('#1647', function() {
|
|||
var result = 'M57.83,48.25l-6.78143,11.75l-2.88143,0l7.50286,-13c0.88236,-1.55771 2.53981,-2.51466 4.33,-2.5v2.5c-0.89493,-0.00177 -1.72254,0.47497 -2.17,1.25z';
|
||||
compareBoolean(path1.intersect(path2), result);
|
||||
});
|
||||
|
||||
test('#1619', function() {
|
||||
var path1 = new Path.Rectangle({
|
||||
from: [200, 600],
|
||||
to: [400, 300]
|
||||
});
|
||||
|
||||
var path2 = new CompoundPath({
|
||||
children: [
|
||||
new Path({
|
||||
segments: [[420,320],[380,580],[220,580],[220,320]],
|
||||
closed: true
|
||||
}),
|
||||
new Path({
|
||||
segments: [[313.36486,413.71682],[243.351,483.70296],[313.33714,553.71682],[383.351,483.73068]],
|
||||
closed: true
|
||||
})
|
||||
]
|
||||
});
|
||||
var result = 'M380,580h-160v-260l180,0v130zM313.36486,413.71682l-70.01386,69.98614l69.98614,70.01386l70.01386,-69.98614z';
|
||||
compareBoolean(path1.intersect(path2), result);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue