1.0.0 • Published 7 months ago

scrambling-ascii-art v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Scrambling ASCII Art

npm version CI

A TypeScript library for creating scrambling ASCII art animations with optional React support.

Features

  • 🎨 ASCII art scrambling animation
  • ⚛️ React component support
  • 🎮 Customizable animation speed and scale
  • 📦 Zero dependencies
  • 💪 TypeScript support
  • 🌐 Browser compatible

Installation

npm install scrambling-ascii-art

Usage

Vanilla JavaScript/TypeScript

import { AsciiScrambleEngine } from 'scrambling-ascii-art';

const container = document.querySelector('#container');
const art = [
  " ∧_∧ ",
  " (。・ω・) ",
  "⊂  ノ ",
  " しーJ ",
];

const scrambler = new AsciiScrambleEngine(container, {
  art: art,
  speed: 80, // Optional: animation speed (default: 40)
  scale: 100 // Optional: display scale in percentage (default: 100)
});

// Start animation
scrambler.scramble().then(() => {
  console.log('Animation completed!');
});

// Stop animation if needed
scrambler.stop();

React Component

import { AsciiScramble } from 'scrambling-ascii-art/react';

function App() {
  const art = [
    " ∧_∧ ",
    " (。・ω・) ",
    "⊂  ノ ",
    " しーJ ",
  ];

  return (
    <AsciiScramble
      art={art}
      speed={80}
      scale={100}
      onComplete={() => console.log('Animation completed')}
    />
  );
}

API Reference

AsciiScramble Options

OptionTypeDefaultDescription
artstring[]RequiredASCII art as array of strings
speednumber40Animation speed (higher is slower)
scalenumber100Display scale in percentage

Methods

MethodReturn TypeDescription
scramble()PromiseStart scrambling animation
stop()voidStop current animation

Contributing

Contributions are welcome! Feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details