8000 Add 2D Canvas DSL w/ GADT interpreter by dmjio · Pull Request #940 · dmjio/miso · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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 20 commits into from
May 14, 2025
Merged

Add 2D Canvas DSL w/ GADT interpreter #940

merged 20 commits into from
May 14, 2025

Conversation

dmjio
Copy link
Owner
@dmjio dmjio commented May 13, 2025

🎨 2D Canvas DSL support

This makes the 2D Canvas API first class in miso's View. Canvas support accessible via the canvas_ tag. Fully supports 2D Canvas API

  • Adds Miso.Canvas module with GADT of Canvas API.
  • Drops legacy FFI
  • Creates draw callback on canvas object
  • Extends dom.ts to invoke synchronous callback to interpret GADT DSL
  • Adds WASM build for 2D canvas (drops js-only cabal option)
  • Adds Image type w/ smart constructor image :: MisoString -> Image to Miso.FFI
  • Extends example to render multiple canvases at the same time
  • Regen JS
  • Adds MonadIO and MonadJSM to DSL
  • Finish interpretation of all Canvas API calls
  • Add additional haddockumentation
  • Add Gradient, and integrate more deeply with Miso.Style.
  • Add test for draw() on canvas_ in spec/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 the View, despite Canvas a now living on View via canvas_

Loosely inspired by @andygill 's https://github.com/ku-fpg/blank-canvas DSL approach, specialized to GHCJS, WASM and jsaddle and miso internals.

dmjio added 4 commits May 13, 2025 16:53
- [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
@dmjio dmjio merged commit 7500d75 into master May 14, 2025
3 checks passed
@dmjio dmjio deleted the canvas-dsl branch May 16, 2025 16:01
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

Successfully merging this pull request may close these issues.

2 participants
0