CKTIS / CSS
paint() — imagen producida por Paint Worklet
`paint()` referencia un pintor JavaScript registrado que produce un `<image>` sensible al tamaño y estilo calculado de la caja.
Versión: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Sintaxis
paint( <ident> [, <declaration-value>]? )paint() referencia un pintor JavaScript registrado que produce un <image> sensible al tamaño y estilo calculado de la caja.
En este Chromium, paint(cktis-grid) indica compatibilidad false, falta CSS.paintWorklet y la imagen calculada es none. Por ello sigue visible el color alternativo, píxel 0,128,0,255; el ejemplo no finge haber ejecutado un paint worklet.
Gramática: paint( <ident> [, <declaration-value>]? ).
El primer argumento es un identificador que coincide con el nombre dado a registerPaint(); el módulo se carga mediante CSS.paintWorklet.addModule(). Los argumentos opcionales se validan al dibujar frente a inputArguments; nombre no registrado, cantidad o tipo erróneos producen una imagen no válida. El pintor puede declarar propiedades observadas y recibe el tamaño de salida, pero no sustituye contenido accesible; en cursor, la función siempre es una imagen no válida y se usa la siguiente alternativa.
Ejemplos
const probe=document.createElement('div');probe.style.cssText='width:8px;height:8px;background-color:rgb(0 128 0);background-image:paint(cktis-grid)';document.body.append(probe);
const supported=CSS.supports('background-image','paint(cktis-grid)');
const worklet=Boolean(CSS.paintWorklet);
const computed=getComputedStyle(probe).backgroundImage;
const svg='<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><foreignObject width="8" height="8"><div xmlns="http://www.w3.org/1999/xhtml" style="width:8px;height:8px;background-color:rgb(0 128 0);background-image:paint(cktis-grid)"></div></foreignObject></svg>';
const image=new Image();image.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(svg);await image.decode();const canvas=document.createElement('canvas');canvas.width=canvas.height=8;const context=canvas.getContext('2d');context.drawImage(image,0,0);const pixel=[...context.getImageData(4,4,1,1).data].join(',');
console.log('supported='+supported+'; paint-worklet='+worklet+'; computed-image='+computed+'; fallback-pixel='+pixel);Resultado
supported=false; paint-worklet=false; computed-image=none; fallback-pixel=0,128,0,255
`paint()` referencia un pintor JavaScript registrado que produce un `<image>` sensible al tamaño y estilo calculado de la caja.