A lit ring turning slowly on two axes, shaded with a classic character ramp.
@@@@@
@@@@@@@@@@@@@@$@@@
$$$$$$$$$##############$
#$$$#$##*#**********!!!!*****
*#####******!!!!!!!!=!!!=!!!!*!!!
*#*****!!!!====;;:::::::::;;;==!==
!**!!!!!!=;=;::~~-----------~~::;;=;
=!!!!====;;::~---,...........,--~~::;
=!!===;;::~--,..................,--~:
;=;;;;::~-,,...... .........,--~
;;:;::~~-,...... ~........,---
::::~~--,....., !!=-,....,,,-,
~~~~~--,,.....-;*#$@@@$#*;:~~----,,
------,,,,..,:=!#$@@@@$*!=;:~~-,.
,,---,,,,--~;=!*##$$#**!=;::-,.
..,,,,---~:;===!!**!*!=;:~,.
...,,,--~:;;===!=;;~-..
....,,,,--,,...
Paste two lines into any page, use it from React, play it in a terminal, put a GIF in a README, or hand the Agent prompt to your coding agent. Every tab follows the look you pick above.
<script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script>
<ascii-art piece="spinning-torus"></ascii-art>// npm install ascii-magic-art
import { useEffect, useRef } from "react";
import { play } from "ascii-magic-art/runtime/player.js";
import * as piece from "ascii-magic-art/pieces/spinning-torus.js";
export function SpinningTorus() {
const ref = useRef(null);
// play() draws the piece on a canvas in your look and returns stop(), which React runs on unmount
useEffect(() => play(ref.current, piece), []);
return <pre ref={ref} style={{ fontSize: 10, fontFamily: "Menlo, Consolas, monospace" }} />;
}npx ascii-magic-art spinning-torus<!-- Export the GIF below in the look you picked, commit it, then: -->
<p align="center">
<img src="assets/spinning-torus.gif" alt="Spinning Torus, animated ASCII art" width="720">
</p>Add the animated ASCII art piece "spinning-torus" (Spinning Torus) from ASCII Magic to this project.
1. Load the script once, in the browser only (in SSR frameworks such as Next.js, load it on the client):
<script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script>
2. Put the piece where it fits best, such as the hero, a loading state, an empty state or the 404 page:
<ascii-art piece="spinning-torus"></ascii-art>
3. Keep a real heading or text next to it (the art is decoration), and size it with the size attribute or CSS.
Preview and options: https://www.ascii-magic.com/ascii/spinning-torus
Rules for coding agents: https://www.ascii-magic.com/ascii/use/ai-coding-agentsPause on the frame you like, pick a look, then download it at an exact size.
MIT licensed and open source on GitHub. It imports one small helper file, kit.js. This is the animation itself: what gets drawn in every frame. The look you pick is applied on top by the player, like a filter, so this file stays the same in every look while the snippets above change with it. Edit it to change the animation; see the docs to make your own.
/* spinning-torus: a lit ring turning on two axes. */
import { Grid, TAU, RAMPS, ramp } from "../lib/kit.js";
export const meta = {
slug: "spinning-torus",
name: "Spinning Torus",
category: "solids",
note: "A lit ring turning slowly on two axes, shaded with a classic character ramp.",
tags: ["3d", "loader", "hero", "terminal"],
cols: 48, rows: 24, fps: 30,
};
export default function create() {
const g = new Grid(meta.cols, meta.rows);
const R1 = 1, R2 = 2.1, K2 = 6;
const K1 = (meta.cols * K2 * 0.36) / (R1 + R2);
const L = [0, 0.7071, -0.7071];
return (t) => {
g.clear();
const A = t * 0.9, B = t * 0.45;
const cA = Math.cos(A), sA = Math.sin(A), cB = Math.cos(B), sB = Math.sin(B);
for (let th = 0; th < TAU; th += 0.08) {
const ct = Math.cos(th), st = Math.sin(th);
for (let ph = 0; ph < TAU; ph += 0.03) {
const cp = Math.cos(ph), sp = Math.sin(ph);
const h = R2 + R1 * ct;
const x = h * (cB * cp + sA * sB * sp) - R1 * st * cA * sB;
const y = h * (sB * cp - sA * cB * sp) + R1 * st * cA * cB;
const z = K2 + cA * h * sp + R1 * st * sA;
const ooz = 1 / z;
const nx = ct * (cB * cp + sA * sB * sp) - st * cA * sB;
const ny = ct * (sB * cp - sA * cB * sp) + st * cA * cB;
const nz = cA * ct * sp + st * sA;
const lum = Math.max(0, nx * L[0] + ny * L[1] + nz * L[2]);
g.setZ(meta.cols / 2 + K1 * ooz * x, meta.rows / 2 - K1 * 0.5 * ooz * y, ooz, ramp(0.08 + lum * 0.92, RAMPS.soft));
}
}
return g.frame();
};
}
/YOUR OWN
The pieces here are hand-built animations. To turn your own photo, logo or video into animated ASCII, use the ASCII Magic editor.