js canvas create pattern repeat issues

Viewed 11

Currently drawing this onto a canvas:

enter image description here

I want to use a texture that repeats only on the Y axis where the red rectangle is.

However, when drawing the texture, nothing shows up when repeat-y is specified. It works when the repeat value is repeat however.

ctx.fillStyle = ctx.createPattern(assets.grassRightTexture, 'repeat-y');
ctx.fillRect(dimensions.left + dimensions.width, dimensions.top, 5, dimensions.height);

The assets.grassRightTexture is a preloaded img element with a 4px by 32px sprite.

Not sure if im doing something wrong but I didnt notice anything when reading the moz canvas docs.

Thank you.

0 Answers
Related