Dzugaru Posted April 25, 2017 Share Posted April 25, 2017 I want to draw some lines and rects, usual strategy for doing this in other game engines is using a 1x1 texture in a scaled and tinted sprite, but in PixiJS I found a strange problem with this. Texture from drawRect(0,0,1,1) doesn't work, while drawRect(0,0,2,2) (or 2x1, 1x2, or 2x2 with frame = new Rectangle(0,0,1,1)) works. https://jsfiddle.net/Dzugaru/84otd4dn/ Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 26, 2017 Share Posted April 26, 2017 Workaround: use PIXI.Texture.WHITE , its 10x10 . And yes, that's probably a bug. Quote Link to comment Share on other sites More sharing options...
Taz Posted April 28, 2017 Share Posted April 28, 2017 You can make a 1x1 texture with generateCanvasTexture by changing your demo like this: var renderer = PIXI.autoDetectRenderer(256, 256); document.body.appendChild(renderer.view); var stage = new PIXI.Container(); var rect = new PIXI.Graphics(); rect.beginFill(0xFFFFFF, 1); rect.drawRect(0, 0, 1, 1); rect.endFill(); ////////////////////////////////////////////////////////////////////////////////////// var tex = rect.generateCanvasTexture(); // ////////////////////////////////////////////////////////////////////////////////////// var s = new PIXI.Sprite(tex); s.width = s.height = 32; s.x = s.y = 128 - s.width / 2; stage.addChild(s); renderer.render(stage); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.