在 Graphic 对象上绘制不带滤镜的阴影

发布于 2024-09-25 12:52:13 字数 737 浏览 11 评论 0原文

我有一个关于精灵或形状的复杂图形数据(无论到底是哪一个)。 但我想为一个矩形(例如 [10, 10, 240, 25])或另一条路径绘制阴影(内部也是)。

  /// code before
  grObj.graphics.drawRect( 10, 10, 240, 25);
      /// -> draw inner shadow on this objcect somehow
  /// code after

是否可以执行无过滤器?

附: http://ipicture.ru/uploads/100927/RHZF1K6Exu.png


解决:

BitmapData(*).applyFilter( *,*,*,*); // play with this function :)

也< a href="http://help.adobe.com/ru_RU/AS3LCR/Flash_10.0/flash/display/BitmapData.html#applyFilter" rel="nofollow">http://help.adobe.com/ru_RU/ AS3LCR/Flash_10.0/flash/display/BitmapData.html#applyFilter()

I have a complex graphics data on a sprite or a shape (no matter which is exactly).
But I want to draw shadow (inner too) for one Rect ( [10, 10, 240, 25] for example) or another path.

  /// code before
  grObj.graphics.drawRect( 10, 10, 240, 25);
      /// -> draw inner shadow on this objcect somehow
  /// code after

Is it possible to perform w\o filters?

ps. http://ipicture.ru/uploads/100927/RHZF1K6Exu.png


solving:

BitmapData(*).applyFilter( *,*,*,*); // play with this function :)

also http://help.adobe.com/ru_RU/AS3LCR/Flash_10.0/flash/display/BitmapData.html#applyFilter()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲世九天 2024-10-02 12:52:14

我假设您不想向对象添加滤镜,因为您计划添加 colorTransform 并且不希望滤镜也改变颜色。

如果是这种情况,您可以通过创建另一个与原始精灵大小相同的精灵来分离滤镜,然后将投影滤镜添加到新精灵中,并将 hideObject 参数设置为 true。

//display object
var grObj:Sprite = new Sprite();
grObj.graphics.beginFill(0xFF0000, 1);
grObj.graphics.drawRect(0, 0, 240, 25);
grObj.graphics.endFill();

//filter object
var dsFilter:Sprite = new Sprite();
dsFilter.graphics.beginFill(0);
dsFilter.graphics.drawRect(0, 0, grObj.width, grObj.height);
dsFilter.graphics.endFill();

dsFilter.filters = [new DropShadowFilter(4.0, 45, 0, 1.0, 4.0, 4.0, 1.0, 3, true, false, true)];

//display list
grObj.x = dsFilter.x = 10;
grObj.y = dsFilter.y = 10;

addChild(grObj);
addChild(dsFilter);

i'm assuming you don't want to add filters to your object because you plan on adding a colorTransform and do not want the filters to also change color.

if that's the case what you can do is separate the filter by creating another sprite of the same size as the original, add a drop shadow filter to the new sprite with the hideObject parameter set to true.

//display object
var grObj:Sprite = new Sprite();
grObj.graphics.beginFill(0xFF0000, 1);
grObj.graphics.drawRect(0, 0, 240, 25);
grObj.graphics.endFill();

//filter object
var dsFilter:Sprite = new Sprite();
dsFilter.graphics.beginFill(0);
dsFilter.graphics.drawRect(0, 0, grObj.width, grObj.height);
dsFilter.graphics.endFill();

dsFilter.filters = [new DropShadowFilter(4.0, 45, 0, 1.0, 4.0, 4.0, 1.0, 3, true, false, true)];

//display list
grObj.x = dsFilter.x = 10;
grObj.y = dsFilter.y = 10;

addChild(grObj);
addChild(dsFilter);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文