SVG <feColorMatrix> Filter

Last Updated:

Whis is <feColorMatrix> Filter?

The <feColorMatrix> SVG filter element changes colors based on a transformation matrix.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> svg rect{ stroke:red; stroke-width:3; fill:#339933; } </style> </head> <body> <svg height="130" width="130"> <defs> <filter id="point" x="0" y="0" width="200%" height="200%"> <feOffset result="offOut" in="SourceGraphic" dx="20" dy="20" /> <feColorMatrix result="matrixOut" in="offOut" type="saturate" values="1"/> <feGaussianBlur result="blurOut" in="matrixOut" stdDeviation="10" /> <feBlend in="SourceGraphic" in2="blurOut" mode="normal" /> </filter> </defs> <rect width="80" height="80" filter="url(#point)" /> </svg> </body> </html>

Attributes Value

AttributeExplanation
in Specifies the input for the given filter primitive.
type Specifies the type of matrix operation.
The following are the list of possible value
  • matrix
  • saturate
  • hueRotate
  • luminanceToAlpha
values The values attribute is a semicolon-separated list of one or more values. The values attribute in feColorMatrix are always depends upon the type attribute value used.
The following are the list of possible values depends upon type attributes value
  • matrix - values is a list of 20 matrix values (a00 a01 a02 a03 a04 a10 a11 ... a34), separated by whitespace and/or a comma.
  • saturate - values is a single real number value (0 to 1).
  • hueRotate - values is a single one real number value (degrees).
  • luminanceToAlpha - values is not applicable.

Share this Page

Meet the Author