Skip to content

feat(examples): add Prism Atelier creative surface example#39

Merged
saraeloop merged 1 commit intomainfrom
feat/prism-atelier-example
Apr 26, 2026
Merged

feat(examples): add Prism Atelier creative surface example#39
saraeloop merged 1 commit intomainfrom
feat/prism-atelier-example

Conversation

@saraeloop
Copy link
Copy Markdown
Member

Summary

Adds Prism Atelier, a vanilla TypeScript creative-coding example that demonstrates DOM-authored HTML/CSS/SVG surfaces as canvas-composited visual material.

What changed

  • Added apps/prism-atelier.
  • Preserved the visual prototype’s studio/gallery direction:
    • dark stage
    • top identity
    • palette tag
    • central generative artwork
    • bottom instrument dock
    • flash/hint/meta readout
    • playful chip controls
  • Replaced the prototype rendering/export path with Prism canvas composition.
  • Changed the default public source word to SURFACE.
  • Added source-aware draw budgets so complex CSS/pattern sources avoid accidental worst-case repeated draw counts.

Prism usage

Atelier:

  • creates a CanvasRuntime
  • requires native backend fidelity
  • registers DOM-authored source nodes as Prism surfaces
  • draws the active source repeatedly inside runtime.onPaint()
  • uses drawSurface() under canvas transforms, alpha, shadows, and blend modes
  • invalidates on input/control changes
  • exports through Prism paint readiness

Registered DOM surfaces:

  • type-surface: HTML/CSS typography
  • glyph-surface: inline SVG prism glyph
  • css-surface: CSS gradient/blob surface
  • pattern-surface: SVG/CSS geometric pattern tile

Implemented modes:

  • Extrude
  • Orbit
  • Trail
  • Split
  • Grid

Export

Export uses the Prism-ready canvas path only:

await document.fonts.ready;
await runtime.paintOnce();
canvas.toBlob(resolve, "image/png");

Add Prism Atelier as a vanilla TypeScript example that demonstrates
DOM-authored HTML/CSS/SVG surfaces as creative canvas material.

Atelier preserves the visual prototype's studio/gallery direction while
replacing the prototype rendering and export path with Prism canvas composition.
The default public artwork uses SURFACE as the source word.

What changed:
- Add apps/prism-atelier.
- Use CanvasRuntime from @synthesisengineering/prism.
- Register DOM-authored source nodes as Prism surfaces:
  - type-surface
  - glyph-surface
  - css-surface
  - pattern-surface
- Draw the active source repeatedly inside runtime.onPaint() using canvas
  transforms, alpha, shadows, blend modes, and pointer-driven offsets.
- Add creative modes:
  - Extrude
  - Orbit
  - Trail
  - Split
  - Grid
- Add source-aware draw budgets so expensive CSS/pattern sources avoid
  accidental worst-case draw counts.
- Add Prism-ready PNG export:
  - document.fonts.ready
  - runtime.paintOnce()
  - canvas.toBlob(..., "image/png")
- Add a native-support gate for non-native environments.
- Add explicit surface registration and disposal helpers.
- Add pagehide/beforeunload cleanup for runtime teardown.
- Add focused teaching comments around Prism surface registration, readiness,
  repeated drawSurface() composition, and cleanup.

This example does not use React, Next.js, Three.js, WebGL, WebGPU,
html2canvas, screenshots, iframe, foreignObject export, or a UI library.

Verification:
- pnpm --filter @prism/example-atelier build
- pnpm e2e
- pnpm test
- pnpm typecheck
- pnpm lint
- pnpm build

Native smoke:
- Confirmed window.prismRuntime.backendKind === "native" with
  canvas-draw-element enabled.
- Confirmed await window.prismRuntime.paintOnce() resolves successfully.

Note:
- Full artwork requires Chromium/Chrome Canary with
  chrome://flags/#canvas-draw-element enabled.
@saraeloop saraeloop self-assigned this Apr 26, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
prism-docs Ready Ready Preview, Comment Apr 26, 2026 6:00pm

@saraeloop saraeloop merged commit bb635e4 into main Apr 26, 2026
7 checks passed
@saraeloop saraeloop deleted the feat/prism-atelier-example branch April 26, 2026 18: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.

1 participant