javascript碰撞检测,d3js

时间:2014-05-14 13:44:13

标签: javascript d3.js collision-detection

在javascript中使用d3.js库向SVG添加元素。单击按钮时会运行以下功能。它只是向SVG添加了一个新的circle元素。我需要帮助的是实现碰撞检测,以便元素不会相互叠加。

    createCircle = function(p) {
    var person = svg.append("circle")
        .attr("cx", Math.random() * svgWidth)
        .attr("cy", Math.random() * svgHeight)
        .attr("r", 20)      
        .attr("class","person")
        .attr("id","p_"+index)
        .style("fill", p.color);
    index++
}

0 个答案:

没有答案