-
-
Notifications
You must be signed in to change notification settings - Fork 144
Add 2D Canvas DSL w/ GADT interpreter #940
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- [x] Add DSL for 2D Canvas API - [x] Update dom.ts to account for canvas
- [x] Adds formatting - [x] Add multiple canvases for rendering - [x] Integrate with dom.ts - [x] Refactor to use GADT - [x] Adds Image to Miso.Internal.FFI, exports
jhrcek
reviewed
May 14, 2025
Ensure draw() callback is invoked.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🎨 2D Canvas DSL support
This makes the 2D Canvas API first class in miso's
View
. Canvas support accessible via thecanvas_
tag. Fully supports 2D Canvas APIMiso.Canvas
module with GADT of Canvas API.draw
callback oncanvas
objectdom.ts
to invoke synchronous callback to interpret GADT DSLjs-only
cabal option)Image
type w/ smart constructorimage :: MisoString -> Image
toMiso.FFI
MonadIO
andMonadJSM
to DSLCanvas
API callsMiso.Style
.draw()
oncanvas_
inspec/dom.ts
The same approach can be used for WebGL (OpenGL ES) for both web and soon mobile.
Addresses #915 partially (WebGL or three.js is next -- to cover last example).
Note: this doesn't violate the purity model, no
IO
can be evaluated in theView
, despiteCanvas a
now living onView
viacanvas_
Loosely inspired by @andygill 's https://github.com/ku-fpg/blank-canvas DSL approach, specialized to GHCJS, WASM and
jsaddle
andmiso
internals.