Giter Site home page Giter Site logo

escapes.js's Introduction

                                                _)
   _ \   __|   __|   _` |  __ \    _ \   __|     |   __|
   __/ \__ \  (     (   |  |   |   __/ \__ \     | \__ \
 \___| ____/ \___| \__,_|  .__/  \___| ____/ _)  | ____/
                          _|                 ___/


  escapes.js is a small JavaScript / Canvas library for rendering ANSI art. It
  has no dependencies, but it integrates nicely with jQuery.

  Demo: http://atdt.github.com/escapes.js/

  Example:

      escapes('path/to/file.ans', function () {
          document.body.appendChild(this);
      });


  Example (with jQuery):

      escapes('path/to/file.ans', function () {
          $(this).appendTo('body');
      });


  Within the callback, the value of "this" is set to a canvas element
  containing the rendered ANSI. The element is augmented with a couple of
  useful methods:

    this.toImageTag()

        Creates an image tag with a PNG of the ANSI.

    this.toDownloadURL()

        Returns a string URL containing the rendered ANSI as a base64-encoded
        PNG file, with a MIME type of "image/octet-stream". If you set this URL
        as the href attribute of a link tag, clicking on it will open a "Save
        File..." dialog.

  escapes() takes a configuration object as an optional third parameter. You
  can use it to make the default background color transparent by passing in
  {transparent: true}.

  If you're using escapes.js with jQuery, you can invoke the library as
  $.ansiRender([url]). This returns a jQuery.Deferred object:

      $.ansiRender('path/to/file.ans').done(function () {
            // do stuff
      });

  Thie chief advantage of this approach is that it allows you to synchronize
  ANSI rendering with other asyncronous operations (using Deferred.when, for
  example). You can read more about jQuery.Deferred here:

  http://api.jquery.com/category/deferred-object/

  For lots & lots of beautiful ANSI art, check out http://sixteencolors.net/

escapes.js's People

Contributors

atdt avatar soycamo avatar jellyfrog avatar andyherbert avatar krinkle avatar

Watchers

James Cloos avatar Tophers 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.