ShotgunJed Posted April 19, 2018 Share Posted April 19, 2018 I know that a texture can be loaded from the website's assets (e.g: "/foo.png"). Is it possible to do something like this: let texture = (some texture from Pixi) document.body.appendChild(<img width=420 height=420 src=texture>); Can a html element use a pixi texture? Quote Link to comment Share on other sites More sharing options...
alex_h Posted April 19, 2018 Share Posted April 19, 2018 You'd want to render the texture to another canvas and append that to the body. Or if you really have to use an image you could render the texture to an off screen canvas, then use canvas toDataUrl to get it into an image element https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL You assign the output of canvas toDataUrl as the image src Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 19, 2018 Share Posted April 19, 2018 `texture.baseTexture.source` is original element, image or canvas. Quote Link to comment Share on other sites More sharing options...
charlie_says Posted April 19, 2018 Share Posted April 19, 2018 I've been a slightly different variant: using a PIXI.Sprite (which has additional content) as an image source var imgSRC = renderer.extract.canvas(mySprite).toDataURL('image/png'); var img = document.createElement('IMG'); img.src = imgSRC; img.style.width = '100%'; img.style.height = 'auto'; document.body.appendChild(img); 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.