Skip to content

Latest commit

 

History

History
151 lines (95 loc) · 2.96 KB

AnsiText.md

File metadata and controls

151 lines (95 loc) · 2.96 KB

<AnsiText>

React component that renders an ANSI animation as HTML text elements.

Syntax

  return (
    <div>
      <AnsiText src="./ansi/hello-world.ans" modemSpeed={2400} />
    </div>
  );

HTML structure

<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>

Props

src

URL to ANSI file (file path for Ink version of component).

Type: <string> or undefined

srcObject

Buffer holding the content of an ANSI file.

Type: <ArrayBuffer> or <string> or <Promise> or undefined

palette

Color palette used for drawing text. Specify

Type: <string[16]> or "css"
Default: CGA Palette

className

The DOM element's class name. Absent from Ink version of component.

Type: <string>
Default: "AnsiText"

modemSpeed

Modem baudrate to emulate. Use Infinity to show the final picture immediately.

Type: <number>
Default: 56000

frameDuration

Duration of an animation frame in millisecond. A shorter duration means a smoother animation.

Type: <number>
Default: 50

blinkDuration

Duration of a blink. Should a multiple of frameDuration.

Type: <number>
Default: 500

blinking

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

transparency

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

minWidth

Type: <number>
Default: 79

minHeight

Type: <number>
Default: 22

maxWidth

Type: <number>
Default: 80

maxHeight

Type: <number>
Default: 25

initialStatus

Type: <object>
Default: { position: 0, playing: true }

beep

Function to call when the beep control code is encountered.

Type: <Function> or undefined
Default: undefined

onStatus

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

onError

Function that receive any error encountered during data retrieval.

Type: <Function> or undefined
Default: undefined

onMetadata

Function that receives any text strings coming after the end-of-file control code.

Type: <Function> or undefined
Default: undefined