你可以得到一个圆的半径,虽然这是间接的。
var radius = circle.bounds.topCenter.y - circle.bounds.center.y;
或
var radius = circle.bounds.width/2
给你一个圆的半径。但是一个圆圈存储为带有句柄的4段线段,而不是圆形对象,因此半径不会存储在任何位置。
为了使它看起来增长,你将不得不删除旧的并绘制一个新的较大的尺寸。
也可以对其进行缩放,但是您希望对其进行缩放而不会混合缩放。所以如果你想要它增长1.01,然后1.02而不是1.0201等,你将需要每次调整缩放因子。
这不是完全清楚你想怎么长大了一圈,但这里的一些代码,让你想要做什么一些假设:
function Scale() {
this.original = 1.0;
this.current = 1.0;
}
// target refers to original size in fractional terms, e.g., to
// grow by 1% specify 1.01 or to shrink by 1% specify 0.99. It returns
// the scale factor to apply to the current scale to achieve the
// target. So to increase the scale by 10% of the original size each
// time:
//
// var s = new Scale();
//
// for (i = 1.1; i <= 2.05; i += 0.1) {
// var scaleFactor = s.scale(i);
// }
//
// note the i <= 2.05 to allow for real number math issues.
//
Scale.prototype.scale = function(target) {
// get the scaling factor from the original size
var oFactor = target/this.original;
// now get the factor to scale the current size by
var cFactor = oFactor/this.current;
this.current = oFactor;
return cFactor;
}
如果我的回答解决你的问题,我将不胜感激你接受的答案通过给它一个绿色的复选标记。 – bmacnaughton