Search code examples
kineticjs

KineticJS version 5.1 paint with mouse setPoints Push


Updating my application form Kinetic 4.3 to 5.1, I used the following to paint line with points array.

layer.on("mousemove", function () {
            if (!drawing) {
                return;
            };
            points.push(stage.getMousePosition());
            line.setPoints(points);
            layer.drawScene();
        }); 

Please see it here http://jsfiddle.net/user373721/9xear3j7/

I changed:

getMousePosition() to getPointerPosition()

It does not work! Is the problem in this line:

 line.setPoints(points);

Please see it at http://jsfiddle.net/user373721/rmvj2vfr/ Would appreciate your suggestions.


Solution

  • Different points API. [x1, y1, x2, y2, ...]

    http://jsfiddle.net/rmvj2vfr/1/