首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >循环colorTransform

循环colorTransform
EN

Stack Overflow用户
提问于 2010-01-03 00:11:42
回答 1查看 819关注 0票数 0

有没有一种方法可以将colorTransform应用于圆形而不是矩形中的BitmapData?

我不想像下面的代码那样通过减少alpha通道来擦除图像中的矩形部分,而是想在圆圈中进行。

代码语言:javascript
复制
 _bitmap.colorTransform(new Rectangle(mouseX-d/2, mouseY-d/2, d, d),
 new ColorTransform(1, 1, 1, .5, 0, 0, 0, 1));

我确实有一些代码循环像素,提取Alpha值并使用setPixel,但它看起来比colorTransform函数慢得多。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-01-03 00:19:49

尝试使用绘图应用编程接口(flash.display.Graphics)创建一个圆,然后使用BlendMode.ERASE将其绘制到位图数据上。如果我理解正确的话,这可能会解决您的问题。

代码语言:javascript
复制
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 blend模式是否能通过draw()命令令人满意地工作,但我不明白为什么它不能。请让我知道它是如何工作的!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1992004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档