是否有一个圆圈,而不是在一个矩形一个ColorTransform应用于BitmapData的方法吗?

相反通过减小α通道如在下面的代码擦除图像的矩形部分的,我想这样做在圆形。

 _bitmap.colorTransform(new Rectangle(mouseX-d/2, mouseY-d/2, d, d),
 new ColorTransform(1, 1, 1, .5, 0, 0, 0, 1));

我确实有一些代码,通过像素循环,提取α值,并使用setPixel但它比的ColorTransform功能显著较慢接缝。

有帮助吗?

解决方案

尝试创建使用绘图API(flash.display.Graphics)一个圆,然后绘制到具有BlendMode.ERASE的位图数据。这可能会解决你的问题,如果我理解正确。

var circle : Shape = new Shape;
circle.graphics.beginFill(0xffcc00, 1);
circle.graphics.drawEllipse(-50, -50, 100, 100);

// Create a transformation matrix for the draw() operation, with
// a translation matching the mouse position.
var mtx : Matrix = new Matrix();
mtx.translate(mouseX, mouseY);

// Draw circle at mouse position with the ERASE blend mode, to
// set affected pixels to alpha=0.
myBitmap.draw(circle, mtx, null, BlendMode.ERASE);

我不是100%肯定的ERASE混合模式与平局()命令的工作令人满意,但我不明白为什么它不应该。请让我知道它是如何工作!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top