Giter Site home page Giter Site logo

asciidance's Introduction

Asciidance

This project is inpired from parrot.live.

Basically i wanted to make any gifs to ascii and make it dance on terminal hence the name asciidance.

So The process of getting this result for any gifs is:

  1. you need a gif
  2. we have to extract frames from gifs
  3. at last we have to turn those frames to ascii

All of this will happen behind the secene when you use asciidance

Here is the quick example
quick example

Install

npm install asciidance

Before running examples

  1. You have to install jp2a on your computer
    1. For installing on Windows use wsl
    2. For installing on Mac use brew
    3. For installing on Ubuntu use sudo apt-get install jp2a
  2. You have to put your gifs on a gifs folder
  3. Everytime you run the code again (as you can see in a quick example above) you have to delete both ascii and frames folder

Example

background

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { bg: "light" });

bg

Custom characters

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { chars: "!@#$%^&()_+" });

custom-chars

Border example

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { border: "border" });

boder

Flip-horizontal

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { flipx: "flipx" });

flipx

Flip-vertical

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { flipy: "flipy" });

flipy

Size

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { size: "100x100" });

size

Width

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { width: "20" });

width

Frame-Rate

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { frameRate: "10" });

frame-rate

Custom-colors

const asciidance = require("asciidance");

asciidance("snoopdog.gif", { customColor: ["green"] });

custom-color

everthing together

const asciiDance = require("asciidance");

asciiDance("snoop.gif", {
  bg: "dark",
  chars: "danielcodex",
  flipy: "flipy",
  flipx: "flipx",
  border: "border",
  frameRate: "100",
  customColor: ["green", "red", "cyan"]
});

everything


API

asciidance(gifFile, asciiConfig?)

gifFile

Type: string
Your gif file name

asciiConfig

Type: object
Default: undefined

Options for how you ascii should look like.

bg

Type: string
Default: dark

The other option is light

Here is the example

chars

Type: string
Default: ...',;:clodxkO0KXNWM

Here is the example

Border

Type: string
Default: undefined

You can set it to border
Here is the example

flipx

Type: string
Default: undefined

You can flip the ascii in the x axis
Here is the example

flipy

Type: string
Default: undefined

you can flip the ascii in the y axis
Here is the example

size

Type: string
Default: The default is the largest image dimension that fits on your terminal link

The format which you write is NxN. That's x in the middle.

Here is the example

frameRate

Type: string
Default: 70

This default rate is originally from parrot.live source code.

But you can change it to any number you want

The rules of thumb is this:
the lower the number the faster the animation/dancing and the higher the number the slower the animation/dancing ๐Ÿ˜‚

Here is the example

customColor

Type: array
Default: ["red", "yellow", "green", "blue", "magenta", "cyan", "white"]

You can give choose any color from default array.
This colors come from colors npm package.

Here is the example


Buggy behaviour

Intentionally i run one code after 2s. Here is the link

For some reason which i don't know yet, if we remove this delay and run the code for the first time, the moment we run curl localhost:3000 we won't get any result in terminal.

So i suspect that the reason for that is because the ascii folder is not populated yet the moment the makeItDance() is called.

That's why i delay the called for makeItDance() function.

If you used a gifs which was really long (i haven't seen a long gifs myself ๐Ÿค”๐Ÿ˜‚) you might not see anything on terminal the moment you run curl localhost:3000.

In order for that to work just run the your code again and then run curl localhost:3000 (it will works, i promise)

Happy coding ๐Ÿค—

asciidance's People

Contributors

danielhemmati avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.