rip Posted October 1 Share Posted October 1 Hi, How can I create a texture from a dynamically generated SVG in pixiJS v8? This worked in v7: const testSVG = '<svg viewBox="0 0 100 100" width="7" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="50" /></svg>' , texture = PIXI.Texture.from(testSVG) but texture logs out as undefined in v8. And this approach: const textureSource = PIXI.TextureSource.from(testsvg ) const texture = PIXI.Texture.from(textureSource) Throws this error: Error: Could not find a source type for resource: <svg viewBox="0 0 100 100" width="7" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="50" /></svg> Thanks! Quote Link to comment Share on other sites More sharing options...
rip Posted October 1 Author Share Posted October 1 I was able to get pixiJS v8 to output an svg with this multi-step process: const renderer = await PIXI.autoDetectRenderer({ preference, clearBeforeRender: true, backgroundAlpha: 0, backgroundColor: 0x000000, width: 500, height: 500 resolution: 1, antialias: false, hello: true }); testsvg = '<SVG viewBox="0 0 100 100" fill="red" width="200" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="50" /></SVG>' const graphics = new PIXI.Graphics().svg(testsvg) , texture = renderer.generateTexture(graphics). , sprite = new PIXI.Sprite(texture) ; I'd still be curious if I'm missing a more straightforward way of outputting an svg in v8, similar to v7's one liner. 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.