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

Feature Request: Texture From SVG With Custom Dimensions #175

Open
fweth opened this issue Jan 17, 2021 · 0 comments
Open

Feature Request: Texture From SVG With Custom Dimensions #175

fweth opened this issue Jan 17, 2021 · 0 comments

Comments

@fweth
Copy link

fweth commented Jan 17, 2021

Hi, apparently width and height are only used in texture options when "src is an array or typed array or null." Would be cool if dimensions could als be specified for a cleanly scaled up SVG. What I do to achieve this manually is creating a canvas in the given dimensions, then use drawImage to draw SVG to canvas and then create the texture from the canvas, like this:

ctx = document.createElement("canvas").getContext("2d");
ctx.canvas.width = width;
ctx.canvas.height = height;
ctx.drawImage(img, 0, 0, width, height);
imgTx = twgl.createTexture(glCtx, { flipY: 1, src: ctx.canvas });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant