A rectangular selection frame with dashes marching clockwise around an empty middle.
┏╌╌╌╌━━━━╌╌╌╌━━━━╌╌╌╌━━━━╌╌╌╌━■━━╌╌╌╌━━━━╌╌╌╌━━━━╌╌╌╌━━━━╌╌┓ ┃ ╎ ╎ ┃ ╎ ┃ ■ ■ ╎ ┃ ┃ ╎ ┃ ╎ ┗━╌╌╌╌━━━━╌╌╌╌━━━━╌╌╌╌━━━━╌╌╌╌■━━━╌╌╌╌━━━━╌╌╌╌━━━━╌╌╌╌━━━━╌┛
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="marching-ants-frame"></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/marching-ants-frame.js";
export function MarchingAntsFrame() {
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 marching-ants-frame<!-- Export the GIF below in the look you picked, commit it, then: -->
<p align="center">
<img src="assets/marching-ants-frame.gif" alt="Marching Ants Frame, animated ASCII art" width="720">
</p>Add the animated ASCII art piece "marching-ants-frame" (Marching Ants Frame) 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="marching-ants-frame"></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/marching-ants-frame
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.
/* marching-ants-frame: a rectangular selection frame with dashes marching around it. */
import { Grid, palette } from "../lib/kit.js";
export const meta = {
slug: "marching-ants-frame",
name: "Marching Ants Frame",
category: "frames",
note: "A rectangular selection frame with dashes marching clockwise around an empty middle.",
tags: ["border", "frame", "selection", "readme", "box"],
cols: 60, rows: 9, fps: 20,
palette: palette(["#e6edf3", "#484f58", "#79c0ff", "#8b949e"]),
};
function perimeter(w, h) {
const p = [];
for (let x = 0; x < w; x++) p.push([x, 0, "h"]);
for (let y = 1; y < h; y++) p.push([w - 1, y, "v"]);
for (let x = w - 2; x >= 0; x--) p.push([x, h - 1, "h"]);
for (let y = h - 2; y >= 1; y--) p.push([0, y, "v"]);
return p;
}
export default function create() {
const { cols, rows } = meta;
const g = new Grid(cols, rows);
const P = perimeter(cols, rows);
const corners = { "0,0": "┏", [`${cols - 1},0`]: "┓", [`0,${rows - 1}`]: "┗", [`${cols - 1},${rows - 1}`]: "┛" };
return (t) => {
g.clear();
const step = Math.floor(t * 10);
P.forEach(([x, y, d], i) => {
const on = (((i - step) % 8) + 8) % 8 < 4;
const c = corners[`${x},${y}`];
if (c) { g.set(x, y, c, "0"); return; }
if (d === "h") g.set(x, y, on ? "━" : "╌", on ? "0" : "1");
else g.set(x, y, on ? "┃" : "╎", on ? "0" : "1");
});
// small resize handles at edge midpoints
const mx = Math.floor(cols / 2), my = Math.floor(rows / 2);
g.set(mx, 0, "■", "2"); g.set(mx, rows - 1, "■", "2");
g.set(0, my, "■", "2"); g.set(cols - 1, my, "■", "2");
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.