Play — ASCII Playground
Andreas Gysin · 2020
Andreas Gysin's browser-based live-coding "playground" (ertdfgcvb.xyz, built on the open-source play.core engine) for writing small programs whose animated visuals are composed entirely of text characters rendered into a grid.
仕組み
アニメーションする画像全体を一つの純粋関数として書くエンジン兼プレイグラウンド。ランナーは 自動サイズの等幅グリッドの各セルごとにユーザープログラムの`main()`を1回呼び、各呼び出しは そこに置く文字(またはスタイル付きセル)を返す。フレームカウンタとポインタが折り込まれ、 アニメーションとインタラクションを与える。
出力からの推測ではなく、play.coreエンジンのソース(`src/run.js`)に基づく。 `run(program, settings, userData)`がフレームごとのループを開始する。各フレームで、プログラムが 読める三つを組み立てる:`context`(`frame`カウンタ、`time`、`cols`、`rows`、フォント`metrics`、 `fps`)、`cursor`(セル座標でのポインタ`x`/`y`、`pressed`、前フレームのカーソル`p`)、そして `cols × rows`個のセルからなる共有`buffer`(各セルは`{char, …style}`で既定は空セル)。`cols`/`rows`は 等幅メトリクスから`floor(width / cellWidth)`×`floor(height / lineHeight)`として要素に自動整合し (または設定で固定)、変化時にバッファは再確保される。省略可能な `program.pre(context, cursor, buffer, userData)`がまず走り、中核は入れ子ループ `for j in rows { for i in cols }`で、各セルについて `program.main({x:i, y:j, index}, context, cursor, buffer, userData)`を呼ぶ。戻り値がそのセルを 決める:文字列は`char`となり、オブジェクトはセルへマージ(`char`と色・太さのスタイル)、偽値の charは空セルに戻る。グリッドを埋めた後に省略可能な`program.post(...)`が走り、レンダラ——既定の DOM `textrenderer`または`canvasrenderer`——がバッファを描く。各セルが `(coord, context, cursor, buffer)`の一関数の出力にすぎないため、動きは`context.frame`/`time`から、 インタラクションは`cursor`から自然に生じる。画像は毎フレーム、文字単位で計算される。
アルゴリズム
- Generative Typography / ASCII 主 · 分類: human-reviewed
詳細
出典
- Web ertdfgcvb.xyz ↗
- GitHub github.com ↗ — The play.core engine repository — first commit 2020-08-26, dating the playground's creation to 2020 (corroborated by Gysin's August 2020 announcement). A later 2023 write-up in Holo covered it, not its release.
関連作品 (共有するアルゴリズムによる)
最終更新 2026-07-16