Watch a demo of different values of the createPattern() method.
Or click a specific value to see the result:
const c = document.getElementById('myCanvas'); const ctx = c.getContext('2d'); const img=document.createElement('img'); img.src='img_lamp.jpg'; const pat=ctx.createPattern(img,'repeat-x'); ctx.rect(0,0,150,100); ctx.fillStyle=pat; ctx.fill();