【问题标题】:Get BBox of a GROUP of Raphael objects?获取一组 Raphael 对象的 BBox?
【发布时间】:2011-02-02 16:59:39
【问题描述】:

获取多个 Raphael 对象作为一个整体的边界框的最佳方法是什么?

我可以将它们全部放在set 中并致电mySet.getBBox() 吗?

或者我需要遍历它们,为每一个获取bbox 并计算整体高度和宽度?

(另外,我不能直接使用 SVG - 我需要 VML 支持。)

【问题讨论】:

    标签: javascript svg raphael vml


    【解决方案1】:

    呃。这真的很容易。 (感谢@Dylan):

    var paper = Raphael ('test', 100, 100);
    
    var circles = paper.set();
    
    var c1 = paper.circle(70,30,10);
    var c2 = paper.circle(50,10,10);
    var c3 = paper.circle(10,80,10);
    
    circles.push(c1, c2, c3);
    
    alert(c3.getBBox().width); // --> 20
    
    alert(circles.getBBox().width); // --> 80
    

    【讨论】:

    • 那不是因为你没有推送circles-set中的c-objects吗?
    • @Dylan - 哇,我的回答大错特错。感谢您的提示 - 现在已在答案中更新。
    猜你喜欢
    • 2011-09-16
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 2012-09-04
    • 2021-03-27
    • 2023-04-08
    • 2021-08-07
    • 2020-02-07
    相关资源
    最近更新 更多