GithubHelp home page GithubHelp logo

bluelich / ascii-morph Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tholman/ascii-morph

0.0 3.0 0.0 7 KB

Library to animate between two ascii images -

Home Page: http://codepen.io/tholman/full/BQLQyo

License: MIT License

JavaScript 100.00%

ascii-morph's Introduction

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.

<!-- Pre elements are perfect for this. -->
<pre class="ascii-element">
</pre>

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

ascii-morph's People

Contributors

brunob avatar tholman avatar

Watchers

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