This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
Add the ability to render HTML Elements to Texture #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
...such as
canvas
,video
,svg
, even with animation.Adds
Texture.fromElement elementId
: load the DOM element content once and use it as a texture;Texture.fromElementWith options elementId
: same as above, but with options;Texture.fromDynamicElement <UseRAF | UseInterval interval> elementId
: load content from the DOM element and userequestAnimationFrame
orsetInterval interval
to ask for the content again and update the texture;ElementNotFound
error;Adds
dynamic-texture.elm
example, which is just a copy ofcrate.elm
, with few changes:Caveats
canvas
,video
itself... The reason is:collage
fromevancz/elm-graphics
is not allowing to set ID to thecanvas
itself, but its wrapper;minify = linear
options is currently forced to be set, or else WebGL fails to render such elements (actually it just shouldn't be the defaultResize Smaller
);requestAnimationFrame
/setInterval
in large amounts;div
), then the error is just reported to console and not returned to the Elm code, since it is fired duringcreateTexture
call;requestAnimationFrame
/setInterval
calls used to update it.Motivation
Usually the source element is hidden, so it’s quite a useful method. For example, I need to show a video in a texture, others also use this method to display text in 3D with almost no hardware tension. Or to add shader-based effects to HTML components, see http://htmlgl.com/.