Toggle this boolean to enable or disable this filter, without removing it from and re-adding it to the Camera's filter list.
ReadonlyallowIf true, this filter will be permitted to draw to the base texture.
This can be unwanted if, for example, the filter doesn't actually
draw anything.
This is an internal flag used by the renderer. You should not modify this value directly.
A reference to the Camera that owns this filter.
The color to use for the key. It is an array of 4 numbers between 0 and 1, representing the RGBA values.
The padding currently being used by this filter.
This is read during rendering via getPadding, and may be updated by subclass implementations.
It is necessary for filters being used in an external list.
You should not modify this value directly.
The feathering amount for the key color. Pixels outside the threshold, but still within the feather, will be a partial match. This should be a value between 0 and 1.
Whether this filter controller will be destroyed when the FilterList that owns it is destroyed. If you enable this, you must ensure that you clean up the filter controller at an appropriate time. This allows you to reuse a controller for multiple objects; this is not recommended unless you know what you're doing. It tends to work best with external filters.
Whether to keep the region matching the key color. If true, the region matching the key color will be kept, and the rest will be removed. If false, the region matching the key color will be removed, and the rest will be kept.
Padding override. This is on by default. If this is set,
the filter will use this padding instead of calculating it.
Prefer using setPaddingOverride instead of modifying this directly.
The ID of the RenderNode that this filter uses.
The threshold for the key color. A pixel is considered to be the key color if the difference between the pixel and the key color is less than the threshold. This should be between 0 and 1. The default threshold is 1 / 16, which is a good starting point for most images.
Destroys this Controller and nulls any references it holds.
Returns the raw padding required for this filter.
This is typically not what you want to call; use getPaddingCeil instead.
Values from this method are not rounded, which can cause quality loss.
Override this method when creating a Filter that requires extra room, e.g. a blur or glow effect.undefined
The padding required by this filter.
Returns the rounded padding required for this filter.
Most filters don't need extra padding, but some may sample beyond the texture boundaries, such as a blur or glow effect.
The bounds are encoded as a Rectangle. To enlarge the bounds, the top and left values should be negative, and the bottom and right values should be positive.
This method calls getPadding() to get the raw padding values,
and uses Math.ceil() to set the values of paddingOverride
and currentPadding.undefined
The rounded padding required by this filter.
Sets the active state of this filter.
A disabled filter will not be used.
true to enable this filter, or false to disable it.
This filter instance.
Sets the alpha value to use for the key. Alpha controls the opacity of pixels matched by the key color, in the range 0 to 1. This is stored in the fourth element of the color array. The RGB color values are preserved.
The alpha value to set on the key texture, between 0 (fully transparent) and 1 (fully opaque).
This Filter Controller.
Sets the color to use for the key. This is stored in the first three elements of the color array. The alpha value is preserved.
The color to use for the key. It can be a hexcode number or string, an array of 3 numbers between 0 and 1, or a Color object.
This Filter Controller.
Sets the padding override.
If this is set, the filter will use this padding instead of calculating it.
Call setPaddingOverride(null) to clear the override.
Call setPaddingOverride() to set the padding to 0.
Optionalleft: number | null
The left padding. Default 0.
Optionaltop: number
The top padding. Default 0.
Optionalright: number
The right padding. Default 0.
Optionalbottom: number
The bottom padding. Default 0.
The Key filter controller.
The Key effect removes or isolates a specific color from an image. It can be used to remove a background color from an image, or to isolate a specific color for further processing.
By default, Key will remove pixels that match the key color. You can instead keep only the matching pixels by setting
isolate.The threshold and feather settings control how closely the key color matches. A match is measured by "distance between color vectors"; that is, how close the RGB values of the pixel are to the RGB values of the key color.
A Key filter is added to a Camera via the FilterList component: