Giter Site home page Giter Site logo

jsascii's Introduction

JavaScript Image ASCIIfier

The ASCIIfier grabs the image from the page and paints it on a hidden canvas element. The pixel data can then be retrieved from the canvas via getImageData() and converted into ASCII text. The original image is then replaced with the new ASCII image. Only every other line in the image is used, since the characters used are twice as tall as they are wide.

Usage

Set to true to convert image to ASCII

asciify=(true/false)

Set to high to use all pixels in image, medium to use every other and low to use only one in four pixels.

asciiresolution=(low/medium/high)

Set to 1 to maintain the size of the original image, 2 to double the size, etc.

asciiscale=(1-5)

Set to true to render the characters in color.

asciicolor=(true/false)

Set to true to render the characters as colored blocks (only if asciicolor=true).

asciiblock=(true/false)

Inverts the character lookup table, so bright becomes dark and vice versa.

asciiinvert=(true/false)

Use a custom character lookup table, default is " .,:;+i1tfLCG08@".

asciichars=("...")

Demo

<html>
<head>
	<title>Hapztron JSASCII</title>
	<script type="text/javascript" src="../jsascii.js"></script>
</head>
<body>
	<img src="img/hapztron.png" 
		asciify="true" 
		asciiresolution="high"
		asciiscale="3" 
		asciicolor="false"
		asciiblock="true"
		asciiinvert="false"
		style="background-color: #FFFFFF;"
	/>
</body>
</html>

Issues and compatibility

  • Only works in capable browsers (no IE)
  • Tested and should work in (at least) Firefox 2 + 3 and Opera 9.5+.
  • There are a bunch of issues with the rendering in Opera, so try different combinations of asciiresolution and asciiscale.

Reference

Original from http://www.nihilogic.dk/labs/jsascii

jsascii's People

Stargazers

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