New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

escapes.js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escapes.js

nodejs version of escapes.js to write ansii art png files

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
                                            _)

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

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 () {
      $(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/

Keywords

FAQs

Package last updated on 05 Jun 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc