Aspect ratio calculator / Typing Nagashino 1575

Typing Nagashino 1575

Code is typed, a battlefield appears in text, and then the battle fights itself.

ASCII · 2026 series · All animations

The code is typed for about 19 seconds, then the battle runs by itself for about a minute and starts again. Press “Skip to Battle” to go straight to the fighting. Free under the MIT License.

What it is

A 16:9 animation in two halves. On the left, eleven lines of code are typed. On the right, the field of the Battle of Nagashino appears as each line is typed: a dusk sky and a crescent moon, Nagashino Castle, a torii gate and pines, the terrace of Shitaragahara and the Rengo River, the wooden palisades, the army of Oda Nobunaga and then the army of Takeda Katsuyori.

When the last line, battle.engage(...), is finished, the picture stops being a drawing and becomes a simulation. 148 soldiers act on their own rules until one side has nobody left to send, the field goes quiet, and it starts again.

What happens in the battle

WhoWhat they do
Oda gunners (24)Stand in three ranks. One rank fires while the next aims and the third reloads, so a volley goes out about every second.
Oda archers (10)Shoot arrows in a high arc over their own lines.
Oda spearmen (28)Hold the line behind the palisades and stab at anything that comes within reach.
Oda reserves (6)Samurai who run to wherever a palisade has been broken.
Takeda cavalry (30)Charge across the river in four waves, ram the palisades, and pour through any gap.
Takeda foot soldiers (40)Follow the horses, shoot arrows on the way in and fight hand to hand at the fence.
The palisadesSix sections, each with its own strength. They crack, splinter and fall as they are hit.
The riverTurns red where soldiers fall in it, and the colour drifts downstream.

The counters at the top show each side’s losses, and the label beside them names the stage: wave 1 charge, three-rank volley, cavalry surge, palisade breach, aftermath. The fallen stay where they fell until the scene starts over.

About the history

The battle was fought in 1575 at Shitaragahara, near Nagashino Castle in what is now Aichi Prefecture, between the allied armies of Oda Nobunaga and Tokugawa Ieyasu and the army of Takeda Katsuyori. The date in the first line, 1575.05.21, is the date in the Japanese calendar of the time; in the Western calendar it was 28 June. Oda’s side waited behind wooden palisades with a large number of matchlock guns, and the Takeda charges broke against them.

The famous three-rank rotating volley is how the battle has been told for centuries, but historians today doubt that it happened in that tidy form. This animation shows the traditional telling. The numbers are also scaled down: tens of thousands fought, and 148 fit on the screen.

How to take it

Press Download the HTML file above to get typing-nagashino-1575.html, or press Copy the code and save it as a file ending in .html. It is one file with no libraries and works offline. To record a video, open the picture-only view and record your screen; the picture is 1920 × 1080.

View the code
Loading…

Embed it on your page

<iframe src="https://aspect.tools/nagashino-code" style="border:0;width:100%;max-width:1180px;aspect-ratio:16/13" title="Typing Nagashino 1575" loading="lazy"></iframe>

License and credit

MIT License. You can use it, change it, share it and sell things made with it, for personal or commercial work. The one condition: keep the copyright and license notice that is at the top of the file.
Typing Nagashino 1575, 2026 series, by aspect.tools (https://aspect.tools/typing-nagashino), MIT License

A visible credit is appreciated but not required.

How to change it

What to changeWhereExample
The text that is typedCODE: one entry per line['// my battle', null]
Typing speedTYPE_SPEED, characters per secondvar TYPE_SPEED = 50;
How long the quiet field staysAFTERMATH_HOLD, in secondsvar AFTERMATH_HOLD = 20;
Play once and stopLOOPvar LOOP = false;
Colours of the two armiesthe col('odaBlue'...) and col('takedaRed'...) linescol('odaBlue', '#6294ff');
How strong each kind of soldier ishp in resetBattlehp: 82 for a spearman
How many waves attackthe loop for (var w = 1; w <= 4; w++) in resetBattleChange 4 to 6 for a longer battle

Questions

Is the battle the same every time?

Nearly. The starting positions are fixed, and the fighting follows rules with a little chance in them, so the result is always similar but small details differ.

Who wins?

Oda Nobunaga's side, as in 1575. The Takeda break some palisades, but their four waves run out first.

Is the three-rank volley historically certain?

No. It is the traditional story of the battle, and many historians now doubt it happened in that neat form. The animation shows the traditional telling.

Does the typed code really run the battle?

No. The typed text is a script for the show. The real code is in the same file, below it, and you can read it.

Can I use it in my own project or video?

Yes. It is under the MIT License for personal and commercial use. Keep the license notice inside the file.

Related tools and guides