|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
<feComposite> merges two inputs (in and in2) into a single output using a Porter-Duff compositing operator.
Unlike "<feBlend>", which mixes the colors of two layers, <feComposite> primarily decides which pixels are kept based on the shapes' alpha channels. It is how you do shape-based masking, intersection, or subtraction inside an SVG filter graph.
If you have ever used boolean shape operations ("intersect", "subtract", "exclude") in a vector editor, Porter-Duff operators are the per-pixel equivalent applied to alpha.
Throughout this page we refer to the two inputs as A (in, the red circle) and B (in2, the blue circle). The diagram below shows what each operator produces when A and B overlap:
A common use of <feComposite operator="in"> is to clip a blurred copy of a shape back to the original shape, producing an inner shadow/glow that stays within the shape's boundaries:
The blur would normally extend outside the shape — <feComposite operator="in"> with in2="SourceAlpha" keeps only the portion of the blur that falls inside the original shape's silhouette, producing the inner-shadow effect.
| Attribute | Default | Description |
|---|---|---|
| in | previous | First input (A). |
| in2 | (none) | Second input (B). Required. |
| operator | over | One of over, in, out, atop, xor, arithmetic. |
| k1 | 0 | Arithmetic coefficient. Only used when operator="arithmetic". |
| k2 | 0 | Arithmetic coefficient. Only used when operator="arithmetic". |
| k3 | 0 | Arithmetic coefficient. Only used when operator="arithmetic". |
| k4 | 0 | Arithmetic coefficient. Only used when operator="arithmetic". |
Inherits standard filter primitive attributes from SVGFilterPrimitiveStandardAttributes (x, y, width, height, result).