4 <canvas id=
"patternCanvas" width=
"8" height=
"32"></canvas>
6 <canvas id=
"canvas" width=
"32" height=
"32"></canvas>
9 const patternCanvas
= document
.getElementById("patternCanvas");
10 const patternCtx
= patternCanvas
.getContext("2d");
11 patternCtx
.fillStyle
= "green";
12 patternCtx
.fillRect(0, 0, patternCanvas
.width
, patternCanvas
.height
);
14 const canvas
= document
.getElementById("canvas");
15 const ctx
= canvas
.getContext("2d");
16 const pattern
= ctx
.createPattern(patternCanvas
, "repeat-x");
17 ctx
.fillStyle
= pattern
;
18 ctx
.fillRect(16, 16, 16, 16);