topical media & game development
actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-BitmapToAsciiConverter.ax
actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-BitmapToAsciiConverter.ax
[swf]
flex
package
{
import flash.display.BitmapData;
/*
* Provides functionality for converting a bitmap image to an "ASCII Art" representation
* of that image.
*/
public class @ax-actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-BitmapToAsciiConverter
{
// ------- Private vars -------
private static const _resolution:Number = .025;
private var _data:BitmapData;
private var _whiteThreshold:Number;
private var _blackThreshold:Number;
/* The characters in this string become increasingly darker.
* This set of characters are the "grayscale values" which are used to create the image.
* There are 64 characters, meaning each character is used to represent four values in a common
* 256-value grayscale color palette (which has color values in the 0-255 range).
* The characters are in order from darkest to lightest, so that their position (index)
* in the string corresponds to a relative color value (with 0 = black).
*/
private static const palette:String = "@#
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.