Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating texture from SVG elements not on SVG image. #2927

Hidejec opened this Issue Sep 8, 2016 · 2 comments


None yet
3 participants
Copy link

Hidejec commented Sep 8, 2016

I created a new Sprite as an SVG image and want to change some contents of the SVG. Now that I achieved changing the contents of an SVG image, I want to Sprite.setTexture(svg) from it. This time the svg is an xml element and not saved as an image file. How to do that please help.
Sorry for my english.


This comment has been minimized.

Copy link

RanzQ commented Sep 8, 2016

@Hidejec I'm currently working on a better SVG support, this might be easier in the future. Anyway, a hack like this might work:

  1. After modifications, convert your SVG element into string using XMLSerializer
  2. Create a texture from data url:
var texture = PIXI.Texture.fromImage('data:image/svg+xml;charset=utf8,' + serializedSvg)

While base64 data urls work too, SVG strings are smaller without base64 conversion.

Afaik this doesn't work in IE though.

UPDATE: A codepen:


This comment has been minimized.

Copy link

lock bot commented Feb 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 25, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.