包 | spark.filters |
类 | public class DisplacementMapFilter |
继承 | DisplacementMapFilter ![]() ![]() ![]() |
实现 | IBitmapFilter |
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
滤镜的具体使用取决于要应用滤镜的对象:
- 要将滤镜应用于显示对象,请使用显示对象的
filters
属性。设置对象的filters
属性不会修改相应的对象,而清除filters
属性可以删除相应的滤镜。 - 要对 BitmapData 对象应用滤镜,请使用
BitmapData.applyFilter()
方法。对 BitmapData 对象调用applyFilter()
会取得源 BitmapData 对象和滤镜对象,并生成一个过滤后的图像。
如果对显示对象应用滤镜,则该显示对象的 cacheAsBitmap
属性值将设置为 true
。如果清除所有滤镜,将恢复 cacheAsBitmap
的原始值。
此滤镜使用以下公式:
dstPixel[x, y] = srcPixel[x + ((componentX(x, y) - 128) * scaleX) / 256, y + ((componentY(x, y) - 128) *scaleY) / 256)
其中,componentX(x, y)
从 mapBitmap
属性获得 (x - mapPoint.x ,y - mapPoint.y)
处的 componentX
属性颜色值。
滤镜使用的映射图像会进行缩放,以匹配舞台缩放比例。当对象自身呈一定的比例时,它不会进行缩放。
此滤镜支持舞台缩放。但不支持常规缩放、旋转和倾斜。如果对象本身进行了缩放(如果将 scaleX
和 scaleY
属性设置为除 1.0 以外的其它值),滤镜效果将不进行缩放。只有用户在舞台上进行放大时它才会缩放。

The <s:DisplacementMapFilter>
tag inherits all of the tag
attributes of its superclass and adds the following tag attributes:
<s:DisplacementMapFilter Properties alpha="0" color="0x000000" componentX="0" componentY="0" mapBitmap="null" mapPoint="null" mode="wrap" scaleX="0" scaleY="0" />
相关 API 元素
flash.display.DisplayObject.filters
flash.display.DisplayObject.cacheAsBitmap
属性 | 由以下参数定义 | ||
---|---|---|---|
alpha : Number
指定对于超出范围的替换应用的 Alpha 透明度值。 | DisplacementMapFilter | ||
color : uint
指定对于超出范围的替换应用什么颜色。 | DisplacementMapFilter | ||
componentX : uint
说明在映射图像中使用哪个颜色通道来置换 x 结果。 | DisplacementMapFilter | ||
componentY : uint
说明在映射图像中使用哪个颜色通道来置换 y 结果。 | DisplacementMapFilter | ||
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
mapBitmap : BitmapData
包含置换映射数据的 BitmapData 对象。 | DisplacementMapFilter | ||
mapPoint : Point
一个值,它包含目标显示对象的左上角相对于映射图像左上角的偏移量。 | DisplacementMapFilter | ||
mode : String
滤镜模式。 | DisplacementMapFilter | ||
scaleX : Number
用于缩放映射计算的 x 置换结果的乘数。 | DisplacementMapFilter | ||
scaleY : Number
用于缩放映射计算的 y 置换结果的乘数。 | DisplacementMapFilter |
方法 | 由以下参数定义 | ||
---|---|---|---|
DisplacementMapFilter(mapBitmap:BitmapData = null, mapPoint:Point = null, componentX:uint = 0, componentY:uint = 0, scaleX:Number = 0.0, scaleY:Number = 0.0, mode:String = "wrap", color:uint = 0, alpha:Number = 0.0)
构造函数。 | DisplacementMapFilter | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。 | EventDispatcher | |
返回此滤镜对象的副本。 | DisplacementMapFilter | ||
![]() |
将事件调度到事件流中。 | EventDispatcher | |
![]() |
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。 | EventDispatcher | |
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
过滤器更改后传播更改事件。 | BaseFilter | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
从 EventDispatcher 对象中删除侦听器。 | EventDispatcher | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
![]() |
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。 | EventDispatcher |
alpha | 属性 |
color | 属性 |
componentX | 属性 |
componentX:uint
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
说明在映射图像中使用哪个颜色通道来置换 x 结果。可能的值为 BitmapDataChannel 常量:
BitmapDataChannel.ALPHA
BitmapDataChannel.BLUE
BitmapDataChannel.GREEN
BitmapDataChannel.RED
默认值为 0, meaning no channel.。
实现
public function get componentX():uint
public function set componentX(value:uint):void
相关 API 元素
componentY | 属性 |
componentY:uint
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
说明在映射图像中使用哪个颜色通道来置换 y 结果。可能的值为 BitmapDataChannel 常量:
BitmapDataChannel.ALPHA
BitmapDataChannel.BLUE
BitmapDataChannel.GREEN
BitmapDataChannel.RED
默认值为 0, meaning no channel.。
实现
public function get componentY():uint
public function set componentY(value:uint):void
mapBitmap | 属性 |
mapBitmap:BitmapData
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
包含置换映射数据的 BitmapData 对象。
默认值为 null。
实现
public function get mapBitmap():BitmapData
public function set mapBitmap(value:BitmapData):void
mapPoint | 属性 |
mode | 属性 |
mode:String
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
滤镜模式。可能的值为 DisplacementMapFilterMode 常量:
DisplacementMapFilterMode.WRAP
- 将置换值折返到源图像的另一侧。DisplacementMapFilterMode.CLAMP
- 将置换值锁定在源图像的边缘。DisplacementMapFilterMode.IGNORE
- 如果置换值超出了范围,则忽略置换并使用源像素。DisplacementMapFilterMode.COLOR
- 如果置换值在图像之外,则替换 color 和 alpha 属性中的值。
默认值为 DisplacementMapFilterMode.WRAP。
实现
public function get mode():String
public function set mode(value:String):void
scaleX | 属性 |
scaleY | 属性 |
DisplacementMapFilter | () | 构造函数 |
public function DisplacementMapFilter(mapBitmap:BitmapData = null, mapPoint:Point = null, componentX:uint = 0, componentY:uint = 0, scaleX:Number = 0.0, scaleY:Number = 0.0, mode:String = "wrap", color:uint = 0, alpha:Number = 0.0)
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
构造函数。
参数mapBitmap:BitmapData (default = null ) — 包含置换映射数据的 BitmapData 对象。
| |
mapPoint:Point (default = null ) — 一个值,它包含目标显示对象的左上角相对于映射图像左上角的偏移量。
| |
componentX:uint (default = 0 ) — 说明在映射图像中使用哪个颜色通道来置换 x 结果。可能的值为 BitmapDataChannel 常量。
| |
componentY:uint (default = 0 ) — 说明在映射图像中使用哪个颜色通道来置换 y 结果。可能的值为 BitmapDataChannel 常量。
| |
scaleX:Number (default = 0.0 ) — 用于缩放映射计算的 x 置换结果的乘数。
| |
scaleY:Number (default = 0.0 ) — 用于缩放映射计算的 y 置换结果的乘数。
| |
mode:String (default = "wrap ") — 滤镜模式。可能的值为 DisplacementMapFilterMode 常量。
| |
color:uint (default = 0 ) — 指定对于超出范围的替换应用什么颜色。置换的有效范围是 0.0 到 1.0。如果 mode 设置为 DisplacementMapFilterMode.COLOR ,则使用此参数。
| |
alpha:Number (default = 0.0 ) — 指定对于超出范围的替换应用什么 Alpha 值。它被指定为 0.0 到 1.0 之间的标准值。例如,0.25 设置透明度值为 25%。如果 mode 设置为 DisplacementMapFilterMode.COLOR ,则使用此参数。
|
相关 API 元素
clone | () | 方法 |
public function clone():BitmapFilter
语言版本: | ActionScript 3.0 |
产品版本: | Flex 4 |
运行时版本: | Flash Player 10, AIR 1.5 |
返回此滤镜对象的副本。
返回BitmapFilter — 具有与原始实例相同的所有属性的新 DisplacementMapFilter 实例。
|
Tue Jun 12 2018, 11:04 AM Z