1

我有创建线

var line1=new Kinetic.Line({

stroke:"blue",
strokeWidth:10,
points:[{"x":152,"y":176},{"x":152,"y":399},{"x":271,"y":399},{"x":271,"y":487},{"x":401,"y":487},{"x":401,"y":370},{"x":541,"y":370},{"x":541,"y":262},{"x":293,"y":262},{"x":293,"y":177}],

})

为了节省我这样做的积分,

var linearray=new Array
linearray=line.getPoints()

它有效,现在我想像这样将点 X 和 Y 保存在不同的数组中,

var linex=new Array()
linex=line.getPoints().x

var liney=new Array()
linex=line.getPoints().y

它不起作用,有什么想法吗?

更新:这是我的小提琴http://jsfiddle.net/skarat001/8kgKx/

4

1 回答 1

0

我会提出这个:

var linex=new Array();
var liney=new Array();

for (var i in line1.getPoints()) {
    linex.push(line1.getPoints()[i].x);
    liney.push(line1.getPoints()[i].y);
}
于 2013-05-30T09:00:33.463 回答