Return to Snippet

Revision: 28197
at July 3, 2010 07:52 by IsoJon


Updated Code
import flash.display.BitmapData;
import flash.display.Bitmap;

// Edit your gradient by hand in the library instance, publish to copy the array for the gradient dictionary.

//** ColorMC is the linkage ID of my bitmap in the library

// this is the height & width of your bitmap
var bitWidth:Number = 255; 
var bitHeight:Number = 10;
var bitArray:Array = new Array();

var colorMC:MovieClip = new ColorMC();
var myBitmapData:BitmapData = new BitmapData(bitWidth, bitHeight);
myBitmapData.draw(colorMC);
var bmp:Bitmap = new Bitmap(myBitmapData);
addChild(bmp);

for (var i = 0; i < bitWidth; i++)
{
	bitArray.push(myBitmapData.getPixel32(i, 1));
	
	if ( bitArray.length == 254 )
	{
		trace( bitArray );
	}
}

Revision: 28196
at July 3, 2010 07:51 by IsoJon


Initial Code
import flash.display.BitmapData;
import flash.display.Bitmap;

// Edit your gradient by hand in the library instance, publish to copy the array for the gradient dictionary.

// this is the height & width of your bitmap
var bitWidth:Number = 255; 
var bitHeight:Number = 10;
var bitArray:Array = new Array();

var colorMC:MovieClip = new ColorMC();
var myBitmapData:BitmapData = new BitmapData(bitWidth, bitHeight);
myBitmapData.draw(colorMC);
var bmp:Bitmap = new Bitmap(myBitmapData);
addChild(bmp);

for (var i = 0; i < bitWidth; i++)
{
	bitArray.push(myBitmapData.getPixel32(i, 1));
	
	if ( bitArray.length == 254 )
	{
		trace( bitArray );
	}
}

Initial URL

                                

Initial Description
I created this snippet as a small utility to populate Michael Vandaniker's Heat Map application with it's necessary gradient information.  

It makes it possible to extract a color array for every pixel of a hand drawn gradient (giving you tons of control over the color and style of the gradient). Check out Michael's Heat Map application here: http://michaelvandaniker.com/blog/2008/07/06/how-to-make-heat-maps-in-flex/

I think this could have numerous other applications. Make something cool.

Initial Title
Get Color Array of handdrawn Gradient

Initial Tags

                                

Initial Language
ActionScript 3