two.js icon indicating copy to clipboard operation
two.js copied to clipboard

How to add a background image to a rectangle?

Open xielonghua opened this issue 3 years ago • 1 comments

I want to add a background image to Two.Rectangle. The size of the background image can be increased to the same size as Two.Rectangle.

xielonghua avatar Aug 11 '22 03:08 xielonghua

There's actually not a great way to do that at the moment. This is because the texture formation is inspired with spritesheet animations in mind. To do what you're asking is a different methodology. I tried to reconcile the two, but it's going to take some time.

Likely, it will be easier to set some configurations on Two.Texture whereby the defaults will be what you're asking and Two.Sprite and Two.ImageSequence will implement additional configurations on the under the hood to keep consistency.

You can see my working branch here: https://github.com/jonobr1/two.js/tree/issue-653-texture-sizing

Not a great answer, but in the meantime I recommend making your image content the actual size you want to use it in. Or, you can use it like this: https://codepen.io/jonobr1/pen/rNdZNwM

jonobr1 avatar Aug 11 '22 19:08 jonobr1