Question

I want to implement a solution that allows me to draw Kinetic.Line with the mouse. My problem is that when I copy-paste my code in a .html file, and although everything works okay in the fiddle, I get this error:

TypeError: line.getPoints(...)[1] is undefined

This is the code I wrote, inspired by some jsfiddles and questions found in SO : http://jsfiddle.net/pg4fm/ What am I doing wrong?

PS: I'm using two KineticJS libraries (v4.7.2 along with v5.0.1) because getPoints() method doesn't work in the v5.0.1. And I need the v5 for other purposes (other functions)

EDIT : This fiddle now work http://jsfiddle.net/pg4fm/2/ But I still need the lines to be straight, just like in the first fiddle

Was it helpful?

Solution

From v5.0.0 KineticJS return points in other way (see docs):

line.getPoints()
>> [x1, y1, x2, y2]

So. It is array of numbers, not objects. Your updated demo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top