Rhiana Heath
GIDS Oct 2020
Software Developer
Blake eLearning
The objective of the CSS-TAG Houdini Task Force (CSS Houdini) is to jointly develop features that explain the “magic” of Styling and Layout on the web.
.triangle-hack {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #000;
}
.clippy-hack {
clip-path: polygon(
10% 0,
90% 0,
100% 10%,
100% 90%,
90% 100%,
10% 100%,
0 90%,
0 10%
);
}
background: paint(magic-bg);
border: paint(magic-border);
mask-image: paint(magic-mask);
<script>
CSS.paintWorklet.addModule('/magic-bg.js');
</script>
registerPaint('magic-bg', class {
static get inputProperties() {
return [
'--bg-colour',
];
}
paint(ctx, geom, properties) {
...
}
});
background: paint(magic-bg);
--bg-colour: #000000;
/* Fallback for older browsers */
background: #000000;
@supports (background: paint(id)) {
background: paint(magic-bg);
--bg-colour: #000000;
}
registerPaint('magic-bg', class {
static get inputProperties() {
return [
'--bg-colour',
];
}
paint(ctx, geom, properties) {
...
}
});
registerPaint('magic-bg', class {
static get inputProperties() {
return [
'--bg-colour',
];
}
paint(ctx, geom, properties) {
const bgColour = properties.get('--bg-colour')
.toString();
}
});
paint(ctx, geom, properties) {
const bgColour = properties.get('--bg-colour')
.toString();
const x = geom.width;
const y = geom.height;
}
paint(ctx, geom, properties) {
const bgColour = properties.get('--bg-colour')
.toString();
const x = geom.width;
const y = geom.height;
ctx.fillStyle = bgColour;
this.drawShape(ctx, geom);
ctx.fill();
}