Add embeddable HTML export from the dial#1
Open
pzep1 wants to merge 1 commit into
Open
Conversation
Adds an "Export" action to the useDialKit panel that downloads a single self-contained HTML file (~20 KB) capturing the live, mouse-reactive system rather than a still frame. The exported file inlines the dither algorithms, particle physics (mouse force field, click shockwaves), render loop, current dial configuration, and the source image as a base64 data URL. No external dependencies — open it directly or drop it in an iframe: <iframe src="dither-embed-...html" style="width:100%;height:600px;border:0"></iframe> Implementation: - src/lib/embed-runtime.ts — vanilla-JS port of the dither/particle modules wrapped in a single function whose source is stringified at build time and inlined into the exported HTML - src/components/particle-canvas.tsx — new "export" dial action, exportArtwork callback, downloadBlob helper Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@pzep1 is attempting to deploy a commit to the leo-6143's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
thanks for OSSing this btw, been fun to play with! I thought maybe its useful for others to have it make a html embeddable |
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
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.
Summary
Adds an Export action to the dial that downloads a single self-contained HTML file capturing the live, interactive dither system — not a still frame.
A first attempt at PNG/SVG export ended up just being a screenshot of whatever happened to be on the canvas at viewport size, which missed the point: the artifact of this project is the mouse-reactive particle animation, not a frozen image. This export packages that animation as a portable, embeddable file.
What gets exported
A ~20 KB standalone
dither-embed-<timestamp>.htmlcontaining:CONFIGobjectNo external requests, no dependencies. Open it directly or drop in an iframe:
Implementation
src/lib/embed-runtime.ts— vanilla-JS port ofdither-algorithms,image-processing, andparticle-system, wrapped in a singlerunDitherEmbed(CONFIG)function. The function's source is stringified viaFunction.prototype.toString()and inlined into the exported HTML bybuildEmbedHTML(). Also exposesimageSrcToDataUrl()for embedding the current image.src/components/particle-canvas.tsx— newexport: { type: "action" }entry in the dial, anexportArtworkcallback that fetches the current image, builds the HTML, and triggers a download. Uses anexportRefto avoid the closure ordering issue withuseDialKit'sonAction.Test plan
dither-embed-<timestamp>.htmlfile downloads🤖 Generated with Claude Code