A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/svg/elements/feColorMatrix below:

feColorMatrix · WebPlatform Docs

feColorMatrix Summary

feColorMatrix is an SVG filter primitive that allows the manipulation of color values across color channels. It provides more powerful color manipulation flexibility than CSS shorthand filters. It is always a child element of an SVG filter element. Using feColorMatrix, you can change color saturation, perform hue rotations, selectively adjust alpha values of particular channels, adjust contrast, brightness and more. feColorMatrix does not allow the manipulation of relative color values *within* color channels which is provided by the feComponentTransfer primitive.

Overview Table
DOM Interface
SVGFEColorMatrixElement

feColorMatrix is a filter primitive that allows the manipulation of color values across color channels. It is always a child element of a [|filter element]. Using feColorMatrix, you can change color saturation, perform hue rotations, selectively adjust alpha values of particular channels, adjust contrast, brightness and more. feColorMatrix does not allow the manipulation of relative color values *within* color channels which is provided by the feComponentTransfer primitive.

Attributes:

Other standard SVG element attributes (style, id, class etc.) may also be added to the element. Like all filter primitives that accept an input, feColorMatrix can accept the following values as input via the “in” attribute.

feColorMatrix offers four types of color manipulation: 3 shorthands and a matrix manipulation:

(It’s important to note that manipulations are applied to *non-pre-multiplied" values*. This means that alpha adjustments (aka. opacity) are unapplied before calculations are performed. This means, for example, that colors that appear similar same visually on a white background (eg. rgba(255,0,0,.5) and rgba(128,0,0,1) can look very different after a feColorMatrix operation. For example, a “saturate=2” will have no effect on the first color, but dramatically redden the second color.)

By default, color-manipulation operations using feColorMatrix take place in linearRGB color space. This may produce unwanted results. For example a color inversion may result in a pronounced shift toward lighter tones. If this is not desired, you may explicitly specify a value of “sRGB” for the optional attribute "color-interpolation-filters".

Examples

Example of a feColorMatrix with type="saturate"

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="saturate">
      <feColorMatrix in="SourceGraphic" type="saturate" values=".5" result="A"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#saturate)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

View live example

Example of a feColorMatrix with type="hueRotate"

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="hueRotate">
      <feColorMatrix in="SourceGraphic" type="hueRotate" values="45" result="A"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#hueRotate)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Example of a feColorMatrix with type="luminanceToAlpha"

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="L2A">
      <feColorMatrix in="SourceGraphic" type="luminanceToAlpha" result="A"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#L2A)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Example of a feColorMatrix with type="matrix" showing a contrast adjustment

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="matrix-contrast">
      <feColorMatrix in="SourceGraphic" type="matrix" values="1.2 0 0 0 -0.2
                                                              0 1.2 0 0 -0.2
                                                              0 0 1.2 0 -0.2
                                                              0 0 0 1 0"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#matrix-contrast)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Example of a feColorMatrix with type="matrix" showing a sepia adjustment

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="matrix-sepia">
      <feColorMatrix in="SourceGraphic" type="matrix" values=".35 .35 .35 0 0
                                                              .25 .25 .25 0 0
                                                              .15 .15 .15 0 0
                                                              0 0 0 1 0"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#matrix-sepia)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Example of a feColorMatrix with type="matrix" showing a standard greyscale adjustment

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="matrix-greyscale">
      <feColorMatrix in="SourceGraphic" type="matrix" values=".33 .33 .33 0 0
                                                              .33 .33 .33 0 0
                                                              .33 .33 .33 0 0
                                                              0 0 0 1 0"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#matrix-greyscale)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Example of a feColorMatrix with type="matrix" showing a greyscale with green channel weighting

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="matrix-greyscale-greenboost">
      <feColorMatrix in="SourceGraphic" type="matrix" values=".25 .5 .25 0 0
                                                              .25 .5 .25 0 0
                                                              .25 .5 .25 0 0
                                                              0 0 0 1 0"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#matrix-greyscale-greenboost)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Example of a feColorMatrix with type="matrix" showing an inversion

<svg width="640" height="550" viewBox="0 0 640 550">
<defs>
    <filter id="matrix-invert">
      <feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1
                                                              0 -1 0 0 1
                                                              0 0 -1 0 1
                                                              0 0 0 1 0"/>
   </filter>
  </defs>
  <image x="10" y="10" width="280" height="350" preserveAspectRatio="true" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
  <image x="310" y="10" width="280" height="350" preserveAspectRatio="true" filter="url(#matrix-invert)" xlink:href="http://upload.wikimedia.org/wikipedia/commons/8/82/Siberian-larch.jpg"/>
</svg>​

***

View live example

Notes Remarks

This filter applies the following matrix transformation:

| R' |     | a00 a01 a02 a03 a04 |   | R |
| G' |     | a10 a11 a12 a13 a14 |   | G |
| B' |  =  | a20 a21 a22 a23 a24 | * | B |
| A' |     | a30 a31 a32 a33 a34 |   | A |
| 1  |     |  0   0   0   0   1  |   | 1 |

This matrix is applied on the RGBA color and alpha values of every pixel on the input graphics to produce a result with a new set of RGBA color and alpha values.

The calculations are performed on non-premultiplied color values. If the input graphics consist of premultiplied color values, those values are automatically converted into non-premultiplied color values for this operation.

Syntax Standards information Members

The SVGFEColorMatrixElement object has these properties:

See also Related articles Filters

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4