React component that renders an ANSI animation as HTML text elements.
return (
<div>
<AnsiText src="./ansi/hello-world.ans" modemSpeed={2400} />
</div>
);
<code className="AnsiText" style="display: inline-block; whiteSpace: pre; width: fit-content">
<div>
<span style="color: [color]; background-color: [color]">[ text ]</span>
<span />
⋮
<span />
</div>
<div />
⋮
<div />
</code>
URL to ANSI file (file path for Ink version of component).
Type: <string>
or undefined
Buffer holding the content of an ANSI file.
Type: <ArrayBuffer>
or <string>
or <Promise>
or undefined
Color palette used for drawing text. Specify
Type: <string[16]>
or "css"
Default: CGA Palette
The DOM element's class name. Absent from Ink version of component.
Type: <string>
Default: "AnsiText"
Modem baudrate to emulate. Use Infinity
to show the final picture immediately.
Type: <number>
Default: 56000
Duration of an animation frame in millisecond. A shorter duration means a smoother animation.
Type: <number>
Default: 50
Duration of a blink. Should a multiple of frameDuration
.
Type: <number>
Default: 500
Whether the blink bit causes text to blink or the selection of bright background colors. Specific
"css"
if you wish to perform blinking through CSS instead. <span>
elements that are suppose
to blink will receive a "blinking" class name.
Type: <number>
or "css"
Default: false
When true
, the default text attributes become [no background]/[no foreground color] instead of
[black]/[gray]. Only works for specially crafted ANSI files. ANSI files created in the BBS era
all assume a default black background.
Type: <number>
Default: false
Type: <number>
Default: 79
Type: <number>
Default: 22
Type: <number>
Default: 80
Type: <number>
Default: 25
Type: <object>
Default: { position: 0, playing: true }
Function to call when the beep control code is encountered.
Type: <Function>
or undefined
Default: undefined
Function that receives the current status, an object containing the property position
and playing
. position
is a number
between 0 and 1, representing the percentage of the file that has been
processed.
Type: <Function>
or undefined
Default: undefined
Function that receive any error encountered during data retrieval.
Type: <Function>
or undefined
Default: undefined
Function that receives any text strings coming after the end-of-file control code.
Type: <Function>
or undefined
Default: undefined