Search code examples
linekineticjspoints

kineticjs line points array contentes


what are the interpretation values in the"" points assignment. all I want is a "plane jane" line where I can manipulate the length and width. Any help will greatly appreciated.

var line = new Kinetic.Line({ x: 100, y: 50, points: [73, 70, 340, 23, 450, 60, 500, 20], stroke: 'red', tension: 1 });


Solution

  • The points array is a series of x,y coordinates:

    // [73, 70, 340, 23, 450, 60, 500, 20],
    
    {x:73,y:70},
    {x:340,y:23},
    {x:450,y:60},
    {x:500,y:20}
    

    This is your "plain jane" line:

    // draw a black line from 25,25 to 100,50 and width of 5
    
    var line = new Kinetic.Line({
        points:[25,25, 100,50],
        y:100,
        stroke: 'black',
        strokeWidth: 5
    });