Skip to content

[css-paint-api] Converting a URL to a CanvasImageSource? #416

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

Closed
asajeffrey opened this issue Jun 20, 2017 · 3 comments
Closed

[css-paint-api] Converting a URL to a CanvasImageSource? #416

asajeffrey opened this issue Jun 20, 2017 · 3 comments

Comments

@asajeffrey
Copy link

PaintRenderingContext2D (https://drafts.css-houdini.org/css-paint-api/#2d-rendering-context) implements CanvasDrawImage (https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage), which uses CanvasImageSource as the type of its image argument (https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource).

In examples such as https://github.com/w3c/web-platform-tests/blob/740aba06484bcb174c692175493fa591d29feedd/css-paint-api/paint2d-image.html#L20, the image is a URL. It is not obvious from the spec how this should be converted to a CanvasImageSource. In particular, paint worklets do not have access to the HTMLImageElement class, as it is not marked Exposed=(Window,PaintWorklet).

@asajeffrey
Copy link
Author

Looking at what Chrome does, the properties map contains a CSSURLImageValue (https://drafts.css-houdini.org/css-typed-om-1/#cssimagevalue). Presumably CanvasImageSource is extended to allow CSSURLImageValue arguments?

@bfgeek
Copy link
Contributor

bfgeek commented Jun 26, 2017

Hey - yeah basically CSSImageValue becomes a valid CanvasImageSource, I had a PR on HTML to extend it in this way for a while, but will write the monkey patch here for the moment instead...

@asajeffrey
Copy link
Author

@bfgeek thanks!

@bfgeek bfgeek closed this as completed in 0cd0557 Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants