#myCanvas
createPattern
repeat|repeat-x|repeat-y|no-repeat
let img=document.createElement('img'); img.src='img_lamp.jpg'; let pat=ctx.createPattern(img,'#val'); ctx.rect(0,0,150,100); ctx.fillStyle=pat; ctx.fill();
your browser does not support the canvas tag
Canvas
❮
Previous
Next
❯
观看不同值的演示
.
或者点击指定值查看结果
在编辑器中更多地使用代码:
亲自尝试一下 ❯