mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 17:21:36 +08:00
added gaurd against infinite slopes for dashed lines
This commit is contained in:
11
dist/kinetic-core.js
vendored
11
dist/kinetic-core.js
vendored
@@ -3848,6 +3848,16 @@ Kinetic.Line.prototype = {
|
||||
var xSlope = dx > dy;
|
||||
var slope = (xSlope) ? dy / dx : dx / dy;
|
||||
|
||||
/*
|
||||
* gaurd against slopes of infinity
|
||||
*/
|
||||
if(slope > 9999) {
|
||||
slope = 9999;
|
||||
}
|
||||
else if(slope < -9999) {
|
||||
slope = -9999;
|
||||
}
|
||||
|
||||
var distRemaining = Math.sqrt(dx * dx + dy * dy);
|
||||
var dashIndex = 0, draw = true;
|
||||
while(distRemaining >= 0.1 && dashIndex < 10000) {
|
||||
@@ -3859,7 +3869,6 @@ Kinetic.Line.prototype = {
|
||||
dashLength = distRemaining;
|
||||
}
|
||||
var step = Math.sqrt(dashLength * dashLength / (1 + slope * slope));
|
||||
|
||||
if(xSlope) {
|
||||
x += dx < 0 && dy < 0 ? step * -1 : step;
|
||||
y += dx < 0 && dy < 0 ? slope * step * -1 : slope * step;
|
||||
|
||||
2
dist/kinetic-core.min.js
vendored
2
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user