PaintWorklet

You can create a CSS image programmatically using the same syntax you use to draw on the canvas.