ColorFilter

Known direct subclasses
BlendModeColorFilter

Creates a color filter that applies the blend mode given as the second argument.

ColorMatrixColorFilter

Create a ColorFilter that transforms colors through a 4x5 color matrix.

LightingColorFilter

Create a ColorFilter that can be used to simulate simple lighting effects.


Effect used to modify the color of each pixel drawn on a Paint that it is installed on

Summary

Public companion functions

ColorFilter
colorMatrix(colorMatrix: ColorMatrix)

Create a ColorFilter that transforms colors through a 4x5 color matrix.

Cmn
ColorFilter
lighting(multiply: Color, add: Color)

Create a ColorFilter that can be used to simulate simple lighting effects.

Cmn
ColorFilter
tint(color: Color, blendMode: BlendMode)

Creates a color filter that applies the blend mode given as the second argument.

Cmn

Extension functions

ColorFilter

Obtain a android.graphics.ColorFilter instance from this ColorFilter

android
ColorFilter

This function is deprecated. Use asSkiaColorFilter()

android
ColorFilter

Obtain a org.jetbrains.skia.ColorFilter instance from this ColorFilter

android

Public companion functions

colorMatrix

fun colorMatrix(colorMatrix: ColorMatrix): ColorFilter

Create a ColorFilter that transforms colors through a 4x5 color matrix. This filter can be used to change the saturation of pixels, convert from YUV to RGB, etc.

Parameters
colorMatrix: ColorMatrix

ColorMatrix used to transform pixel values when drawn

lighting

fun lighting(multiply: Color, add: Color): ColorFilter

Create a ColorFilter that can be used to simulate simple lighting effects. A lighting ColorFilter is defined by two parameters, one used to multiply the source color and one used to add to the source color

Parameters
multiply: Color

Color used to multiply the source color when the color filter is applied.

add: Color

Color that will be added to the source color when the color filter is applied.

tint

fun tint(color: Color, blendMode: BlendMode = BlendMode.SrcIn): ColorFilter

Creates a color filter that applies the blend mode given as the second argument. The source color is the one given as the first argument, and the destination color is the one from the layer being composited.

The output of this filter is then composited into the background according to the Paint.blendMode, using the output of this filter as the source and the background as the destination.

Parameters
color: Color

Color used to blend source content

blendMode: BlendMode = BlendMode.SrcIn

BlendMode used when compositing the tint color to the destination

Extension functions

asAndroidColorFilter

fun ColorFilter.asAndroidColorFilter(): ColorFilter

Obtain a android.graphics.ColorFilter instance from this ColorFilter

asDesktopColorFilter

fun ColorFilter.asDesktopColorFilter(): ColorFilter

Obtain a reference to the desktop ColorFilter type