added gaurd against infinite slopes for dashed lines

This commit is contained in:
Eric Rowell
2012-05-13 16:23:58 -07:00
parent 5045c3fbc4
commit 1c36f208c0
3 changed files with 21 additions and 3 deletions

11
dist/kinetic-core.js vendored
View File

@@ -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;

File diff suppressed because one or more lines are too long