var ctx = document.querySelector("#img").getContext("2d") ctx.fillStyle="rgba(255,255,255,0.3)" ctx.beginPath() ctx.moveTo(0, 50) ctx.bezierCurveTo(80, 30, 220,70, 300, 50) ctx.bezierCurveTo(380, 30,520,70, 600,50) ctx.lineTo(600, 100) ctx.lineTo(0, 100) ctx.closePath() ctx.fill() document.querySelectorAll('.inner').forEach(function(el){ el.style.backgroundImage="url("+ctx.canvas.toDataURL()+")"; })