import Point from "../geom/Point"; import DisplacementMapFilterMode from "./DisplacementMapFilterMode"; import BitmapFilter from "./BitmapFilter"; import BitmapData from "../display/BitmapData"; declare namespace openfl.filters { /** * The DisplacementMapFilter class uses the pixel values from the specified * BitmapData object (called the _displacement map image_) to perform a * displacement of an object. You can use this filter to apply a warped or * mottled effect to any object that inherits from the DisplayObject class, * such as MovieClip, SimpleButton, TextField, and Video objects, as well as * to BitmapData objects. * * The use of filters depends on the object to which you apply the filter: * * * To apply filters to a display object, use the `filters` property of the * display object. Setting the `filters` property of an object does not * modify the object, and you can remove the filter by clearing the `filters` * property. * * To apply filters to BitmapData objects, use the * `BitmapData.applyFilter()` method. Calling `applyFilter()` on a BitmapData * object takes the source BitmapData object and the filter object and * generates a filtered image. * * If you apply a filter to a display object, the value of the * `cacheAsBitmap` property of the display object is set to `true`. If you * clear all filters, the original value of `cacheAsBitmap` is restored. * * The filter uses the following formula: * * ``` * dstPixel[x, y] = srcPixel[x + ((componentX(x, y) - 128) * scaleX) / 256, y + ((componentY(x, y) - 128) * scaleY) / 256) * ``` * * where `componentX(x, y)` gets the `componentX` property color value from * the `mapBitmap` property at `(x - mapPoint.x ,y - mapPoint.y)`. * * The map image used by the filter is scaled to match the Stage scaling. It * is not scaled when the object itself is scaled. * * This filter supports Stage scaling. However, general scaling, rotation, * and skewing are not supported. If the object itself is scaled (if the * `scaleX` and `scaleY` properties are set to a value other than 1.0), the * filter effect is not scaled. It is scaled only when the user zooms in on * the Stage. * * @see `openfl.display.DisplayObject.filters` * @see `openfl.display.BitmapData.applyFilter` * */ export class DisplacementMapFilter extends BitmapFilter { /** * Initializes a DisplacementMapFilter instance with the specified * parameters. * * @param mapBitmap A BitmapData object containing the displacement map * data. * @param mapPoint A value that contains the offset of the upper-left * corner of the target display object from the * upper-left corner of the map image. * @param componentX Describes which color channel to use in the map * image to displace the _x_ result. Possible values * are the BitmapDataChannel constants. * @param componentY Describes which color channel to use in the map * image to displace the _y_ result. Possible values * are the BitmapDataChannel constants. * @param scaleX The multiplier to use to scale the _x_ displacement * result from the map calculation. * @param scaleY The multiplier to use to scale the _y_ displacement * result from the map calculation. * @param mode The mode of the filter. Possible values are the * DisplacementMapFilterMode constants. * @param color Specifies the color to use for out-of-bounds * displacements. The valid range of displacements is * 0.0 to 1.0. Use this parameter if `mode` is set to * `DisplacementMapFilterMode.COLOR`. * @param alpha Specifies what alpha value to use for out-of-bounds * displacements. It is specified as a normalized value * from 0.0 to 1.0. For example, .25 sets a * transparency value of 25%. Use this parameter if * `mode` is set to `DisplacementMapFilterMode.COLOR`. * */ constructor(mapBitmap?: BitmapData, mapPoint?: Point, componentX?: number, componentY?: number, scaleX?: number, scaleY?: number, mode?: DisplacementMapFilterMode, color?: number, alpha?: number); /** * Specifies the alpha transparency value to use for out-of-bounds * displacements. It is specified as a normalized value from 0.0 to 1.0. * For example, .25 sets a transparency value of 25%. The default value * is 0. Use this property if the `mode` property is set to * `DisplacementMapFilterMode.COLOR`. * */ get alpha(): number; set alpha(value: number) /** * Specifies what color to use for out-of-bounds displacements. The valid * range of displacements is 0.0 to 1.0. Values are in hexadecimal * format. The default value for `color` is 0. Use this property if the * `mode` property is set to `DisplacementMapFilterMode.COLOR`. * */ get color(): number; set color(value: number) /** * Describes which color channel to use in the map image to displace the * _x_ result. Possible values are BitmapDataChannel constants: * * `BitmapDataChannel.ALPHA` * * `BitmapDataChannel.BLUE` * * `BitmapDataChannel.GREEN` * * `BitmapDataChannel.RED` * */ get componentX(): number; set componentX(value: number) /** * Describes which color channel to use in the map image to displace the * _y_ result. Possible values are BitmapDataChannel constants: * * `BitmapDataChannel.ALPHA` * * `BitmapDataChannel.BLUE` * * `BitmapDataChannel.GREEN` * * `BitmapDataChannel.RED` * */ get componentY(): number; set componentY(value: number) /** * A BitmapData object containing the displacement map data. * * @throws TypeError The BitmapData is null when being set * */ get mapBitmap(): BitmapData; set mapBitmap(value: BitmapData) /** * A value that contains the offset of the upper-left corner of the * target display object from the upper-left corner of the map image. * * @throws TypeError The Point is null when being set * */ get mapPoint(): Point; set mapPoint(value: Point) /** * The mode for the filter. Possible values are DisplacementMapFilterMode * constants: * * `DisplacementMapFilterMode.WRAP` — Wraps the displacement value to * the other side of the source image. * * `DisplacementMapFilterMode.CLAMP` — Clamps the displacement value * to the edge of the source image. * * `DisplacementMapFilterMode.IGNORE` — If the displacement value is * out of range, ignores the displacement and uses the source pixel. * * `DisplacementMapFilterMode.COLOR` — If the displacement value is * outside the image, substitutes the values in the `color` and `alpha` * properties. * * @throws ArgumentError The mode string is not one of the valid types * @throws TypeError The String is null when being set * */ get mode(): DisplacementMapFilterMode; set mode(value: DisplacementMapFilterMode) /** * The multiplier to use to scale the _x_ displacement result from the * map calculation. * */ get scaleX(): number; set scaleX(value: number) /** * The multiplier to use to scale the _y_ displacement result from the * map calculation. * */ get scaleY(): number; set scaleY(value: number) override clone(): BitmapFilter; } } export default openfl.filters.DisplacementMapFilter;