--- title: paint() slug: orphaned/Web/CSS/paint() tags: - CSS - Fonction - Houdini - Reference - Web translation_of: Web/CSS/paint() original_slug: Web/CSS/paint() ---
La fonction CSS paint() définit une {{cssxref("<image>")}} dont la valeur est générée par un PaintWorklet.
paint(workletName, parameters)
workletNameparametersIl est possible de passer des arguments supplémentaires grâce à la fonction CSS paint(). Dans cet exemple, on passe deux arguments : le premier indiquant si l'arrière-plan est rempli ou si on utilise juste son contour et le second indiquant la largeur de ce contour :
li {
--boxColor: hsla(55, 90%, 60%, 1.0);
background-image: paint(hollowHighlights, stroke, 2px);
}
li:nth-of-type(3n) {
--boxColor: hsla(155, 90%, 60%, 1.0);
background-image: paint(hollowHighlights, filled, 3px);
}
li:nth-of-type(3n+1) {
--boxColor: hsla(255, 90%, 60%, 1.0);
background-image: paint(hollowHighlights, stroke, 1px);
}
On a ici ajouté une propriété personnalisée dans le sélecteur du bloc. Ces propriétés personnalisées peuvent être manipulées par le PaintWorklet.
{{EmbedLiveSample("Examples", 300, 300)}}
| Spécification | État | Commentaires |
|---|---|---|
| {{SpecName('CSS Painting API', '#paint-notation', 'Paint Notation')}} | {{Spec2('CSS Painting API')}} | Définition initiale. |
{{Compat("css.types.image.paint")}}