Need help with ascii-morph?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

tholman
454 Stars 36 Forks MIT License 13 Commits 0 Opened issues

Description

Library to animate between two ascii images -

Services available

!
?

Need anything else?

Contributors list

# 15,942
CSS
svg
GitHub
slack
11 commits
# 41,800
HTML
CSS
web-edi...
Nextclo...
1 commit

AsciiMorph

AsciiMorph is a small stand alone javascript library for rendering ascii art and creations into elements, allowing for them to be changed out with a morphing transition.

Demo

Here's a gif of it in action. You can also play with the demo live here.

Ascii Morph in action

Usage

You'll need an

dom
element for the ascii's to be rendered within.

Next up, you will want to initialize the library. The second parameter is the

width
and
height
properties you want in your rendering square. The ascii will be rendered centered within them, and fill the rest with white space. Naturally this looks best with monospace fonts.
// Initialize AsciiMorph
var element = document.querySelector('pre');
AsciiMorph(element, {x: 50,y: 25});

Then you can get to the fun, rendering elements, and morphing between them.

// First, define some ascii art.
var bird = [
 "                             /",
 "                            /",
 "                           /;",
 "                          //",
 "                         ;/",
 "                       ,//",
 "                   _,-' ;_,,",
 "                _,'-_  ;|,'",
 "            _,-'_,..--. |",
 "    ___   .'-'_)'  ) _)\\|      ___",
 "  ,'\"\"\"`'' _  )   ) _)  ''--'''_,-'",
 "-={-o-  /|    )  _)  ) ; '_,--''",
 "  \\ -' ,`.  ) .)  _)_,''|",
 "   `.\"(   `------''     /",
 "     `.\\             _,'",
 "       `-.____....-\\\\",
 "                 || \\\\",
 "                 // ||",
 "                //  ||",
 "            _-.//_ _||_,",
 "              ,'  ,-'/"
 ]

var mona = [ " ____", " o8%8888,", " o88%8888888.", " 8'- -:8888b", " 8' 8888", " d8.-=. ,==-.:888b", " >8 ~ :~' d8888", " 88 ,88888", " 88b. -~ ':88888", " 888b == .:88888", " 88888o--:':::8888", " 88888| :::' 8888b", " 8888^^' 8888b", " d888 ,%888b.", " d88% %%%8--'-.", "/88:.__ , _%-' --- -", " '''::===..-' = --. ", ]

// Then, you can render (will render instantly) AsciiMorph.render(bird);

// Then morph, to a new creation AsciiMorph.morph(mona);

License

Copyright (c) 2016 Tim Holman - http://tholman.com

The MIT License

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.