mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Use epsilons when deciding for horizontal winding and dealing with horizontal mono-curves.
Relates to #890#issuecomment-169672571, fixing the 2nd case of the 2nd example.
This commit is contained in:
parent
bc8fb92b9d
commit
36a98706b3
1 changed files with 5 additions and 2 deletions
|
@ -434,7 +434,7 @@ PathItem.inject(new function() {
|
|||
// changes between before and after the curve, we treat
|
||||
// this as a 'touch point'.
|
||||
if (prevWinding && nextWinding
|
||||
&& py === values[1]
|
||||
&& abs(py - values[1]) < epsilon
|
||||
&& (values[0] < xAfter && values[6] > xBefore
|
||||
|| values[6] < xAfter && values[0] > xBefore)
|
||||
&& prevWinding.winding * nextWinding.winding < 0) {
|
||||
|
@ -937,7 +937,10 @@ Path.inject(/** @lends Path# */{
|
|||
function insertCurve(v) {
|
||||
var y0 = v[1],
|
||||
y1 = v[7],
|
||||
winding = y0 === y1
|
||||
// Look at the slope of the line between the mono-curve's anchor
|
||||
// points with some tolerance to decide if it is horizontal.
|
||||
winding = Math.abs((y0 - y1) / (v[0] - v[6]))
|
||||
< /*#=*/Numerical.GEOMETRIC_EPSILON
|
||||
? 0 // Horizontal
|
||||
: y0 > y1
|
||||
? -1 // Decreasing
|
||||
|
|
Loading…
Reference in a new issue