Animated ASCII Art for Web Pages

Animated ASCII Art for Web Pages

191 animated ascii pieces for web pages: 13 full-colour scenes like the one above, loaders, charts, type, 27 language logos and 22 Linux distros in colour or one ink, and 3D shapes, physics and creatures. Each is a small, typed TypeScript module with no dependencies, for React, Next.js, Astro, or a plain HTML page, and free to use and change under the MIT license.

适用于网页的 191 个 ASCII 动画作品:包括 13 个如上所示的全彩场景、加载器、图表、字体,27 个编程语言 Logo 和 22 个彩色或单色 Linux 发行版图标,以及 3D 形状、物理效果和生物。每一个都是小型、带类型的 TypeScript 模块,无任何依赖,可用于 React、Next.js、Astro 或纯 HTML 页面,并可在 MIT 许可下免费使用和修改。

No install and no build step. ascii.js defines the tag, loads the piece from ascii.rest, plays it while it is on screen, and holds the first frame for anyone who prefers reduced motion.

无需安装,无需构建步骤。ascii.js 定义了 <ascii-art> 标签,从 ascii.rest 加载作品,在屏幕显示时播放,并为偏好减少动态效果的用户保留第一帧画面。

A client component, so it works in the Next.js app router as it is. Pass the name instead, piece=“donut”, to fetch the piece only when it mounts.

这是一个客户端组件,因此可以直接在 Next.js 的 App Router 中使用。只需传入名称(例如 piece=“donut”),即可在组件挂载时获取该作品。

Renders the first frame on the server, so the page is whole before any script runs, then plays the piece once it loads.

在服务器端渲染第一帧,确保在任何脚本运行前页面内容完整,待加载完成后再播放动画。

mount plays a piece in a

, or on a  for the coloured ones, and returns a function that stops it. Every piece, option and frame is typed.

mount 方法会在 <pre> 标签中播放作品,若是彩色作品则在 <canvas> 中播放,并返回一个用于停止播放的函数。每一个作品、选项和帧都经过了类型定义。