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

Specify what the viewport should be when drawing SVG to a canvas #1880

Open
jakearchibald opened this Issue Oct 10, 2016 · 2 comments

Comments

4 participants
@jakearchibald
Collaborator

jakearchibald commented Oct 10, 2016

I've filed an issue with SVG, as displaying SVG in an image doesn't seem well-defined w3c/svgwg#289

However, we need to define how SVG is drawn to a canvas, particularly in terms of media queries.

canvas2dContext.drawImage(img, x, y, width, height);

Edge uses the layout size of the <img> to determine the viewport. If the <img> doesn't have layout then it falls back to the width/height attributes, if it doesn't have those it falls to the intrinsic dimensions of the <img>. This seems ideal, as you can change the viewport independent of the size it's drawn to the canvas.

At the moment every browser does something different here. Documentation and demos: https://jakearchibald.com/2016/svg-media-queries/#drawing-svg-to-a-canvas

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Oct 11, 2016

Member

@junov @xidachen @grorg any opinions on this question of drawing a SVG to a canvas? Does aligning with Edge's behavior here sound reasonable, if we write some web platform tests and update the spec to be precise?

Member

domenic commented Oct 11, 2016

@junov @xidachen @grorg any opinions on this question of drawing a SVG to a canvas? Does aligning with Edge's behavior here sound reasonable, if we write some web platform tests and update the spec to be precise?

@junov

This comment has been minimized.

Show comment
Hide comment
@junov

junov Oct 11, 2016

Collaborator

I agree with @jakearchibald that Edge's behavior is probably the more desirable one for web devs. The "bizarro-pants" behavior in Chrome is based on a (possibly incorrect) literal interpretation of the spec, which I agree is not that useful.

Collaborator

junov commented Oct 11, 2016

I agree with @jakearchibald that Edge's behavior is probably the more desirable one for web devs. The "bizarro-pants" behavior in Chrome is based on a (possibly incorrect) literal interpretation of the spec, which I agree is not that useful.

@zcorpan zcorpan added interop and removed compat labels Mar 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment