--- title: slug: Web/SVG/Element/feComposite tags: - Element - SVG - SVG Filter translation_of: Web/SVG/Element/feComposite --- {{SVGRef}} La primitive de filtre [SVG](/fr/docs/Web/SVG) **``** effectue la combinaison de deux images en entrée, pixel par pixel, en utilisant une des opérations de composition de Porter-Duff: `over`_,_ `in`_,_ `atop`_,_ `out`_,_ `xor`, et `lighter`. Il est également possible d'appliquer une opération de type `arithmetic` (avec un résultat borné entre \[0..1]). L'opération `arithmetic` est utile pour combiner le résultat de {{SVGElement("feDiffuseLighting")}} et {{SVGElement("feSpecularLighting")}} avec des textures. Si l'opération `arithmetic` est choisie, chaque pixel est calculé à l'aide de la formule suivante: ```plain result = k1*i1*i2 + k2*i1 + k3*i2 + k4 ``` où - `i1` et `i2` indiquent les valeurs des pixels correspondant aux images en entrée, {{SVGAttr("in")}} et {{SVGAttr("in2")}} respectivement - `k1, k2, k3` et `k4` indiquent les valeurs des attributs du même nom ## Contexte d'utilisation {{svginfo}} ## Attributs ### Attributs globaux - [Attributs de base](/fr/docs/Web/SVG/Attribute#Attributs_de_présentation) - [Attributs de présentation](/fr/docs/Web/SVG/Attribute#Presentation_attributes) - [Attributs de primitive de filtre](/fr/docs/Web/SVG/Attribute#Attributs_de_primitives_de_filtre) - {{SVGAttr("class")}} - {{SVGAttr("style")}} ### Attributs spécifiques - {{SVGAttr("in")}} - {{SVGAttr("in2")}} - {{SVGAttr("operator")}} - {{SVGAttr("k1")}} - {{SVGAttr("k2")}} - {{SVGAttr("k3")}} - {{SVGAttr("k4")}} ## Interface DOM Cet élément implémente l'interface {{domxref("SVGFECompositeElement")}}. ## Exemple ### SVG Example feComposite - Examples of feComposite operations Four rows of six pairs of overlapping triangles depicting the six different feComposite operators under different opacity values and different clearing of the background. Define two sets of six filters for each of the six compositing operators. The first set wipes out the background image by flooding with opaque white. The second set does not wipe out the background, with the result that the background sometimes shines through and is other cases is blended into itself (i.e., "double-counting"). Render the examples using the filters that draw on top of an opaque white surface, thus obliterating the background. opacity 1.0 (with feFlood) opacity 0.5 (with feFlood) over in out atop xor arithmetic Render the examples using the filters that do not obliterate the background, thus sometimes causing the background to continue to appear in some cases, and in other cases the background image blends into itself ("double-counting"). opacity 1.0 (without feFlood) opacity 0.5 (without feFlood) over in out atop xor arithmetic ### Résultat Cette image affine le résultat désiré. ![Example feComposite — Examples of feComposite operations](https://www.w3.org/TR/SVG11/images/filters/feComposite.png) ## Spécifications | Spécification | Statut | Commentaire | | ------------------------------------------------------------------------------------------------------------ | -------------------------------- | ------------------------------------------------------ | | {{SpecName('Filters 1.0', '#feCompositeElement', '<feComposite>')}} | {{Spec2('Filters 1.0')}} | Ajoute la valeur `lighter` pour l'attribut `operator`. | | {{SpecName('SVG1.1', 'filters.html#feCompositeElement', '<feComposite>')}} | {{Spec2('SVG1.1')}} | Définition initiale | ## Compatibilité des navigateurs {{Compat("svg.elements.feComposite")}} ## Voir aussi - {{SVGElement("filter")}} - {{SVGElement("animate")}} - {{SVGElement("set")}} - {{SVGElement("feBlend")}} - {{SVGElement("feColorMatrix")}} - {{SVGElement("feComponentTransfer")}} - {{SVGElement("feConvolveMatrix")}} - {{SVGElement("feDiffuseLighting")}} - {{SVGElement("feDisplacementMap")}} - {{SVGElement("feFlood")}} - {{SVGElement("feGaussianBlur")}} - {{SVGElement("feImage")}} - {{SVGElement("feMerge")}} - {{SVGElement("feMorphology")}} - {{SVGElement("feOffset")}} - {{SVGElement("feSpecularLighting")}} - {{SVGElement("feTile")}} - {{SVGElement("feTurbulence")}} - [Tutoriel SVG: Filtres](/fr/docs/Web/SVG/Tutoriel/filtres "en/SVG/Tutorial/Filter_effects")