旋转字符甜甜圈
Donut math: how donut.c works,Andy Sloane (a1k0n),2011 年

正在布展…
它是怎么做的
- 第 1 步用两个角度参数化环面上的点,再绕两条轴旋转。
- 第 2 步透视投影到 80×22 的字符屏,保留 1/z 作为深度缓冲。
- 第 3 步曲面法线与光源方向点积得到亮度,映射到 12 级字符梯度。
- 第 4 步每帧重算整屏字符串并写入 <pre>。
复刻配方
一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。
Sample a torus with two nested angle loops, rotate each point and its normal by two time-varying angles, and project with a simple perspective divide onto a character grid. Keep an inverse-depth buffer per cell so nearer samples win. Compute luminance as the dot product of the normal with a fixed light vector and pick a glyph from a ramp of about a dozen characters. Join the rows into a string and set it as textContent of a <pre> every frame; optionally render the same samples as tiny canvas dots to show the parallel.
档案
能不能拿来用
原作不是开源许可(proprietary — inspiration only):只能作为视觉参考,不要复制它的代码或素材,自己按技术思路实现。
性能开销
视觉强度
实现难度
尺度为策展判断(1 到 5),用于比较和推荐。
核实记录:Opened the article (HTTP 200, title 'Donut math: how donut.c works'); page contains 2 <canvas> elements for the live demos. No repository.


