Hi list!
I was trying to create a little class that generates a 2d grid from a
perlinNoise-bitmap image. Now, when I perform the getPixel32(), it
returns a negative value. I did some research and it appears you can get
'-1' when the indexes are out of bounds, but that's as negative as it
goes... And I am getting results as:
pixel = -16777216
pixel = -16119286
pixel = -15724528
pixel = -15658735
Here is my (relevant) code:
private function createBitmap():Void
{
bmd = new BitmapData(this.width, this.height);
bmd.perlinNoise(this.width, this.height, 6, 1, false, false, 1,
true);
_root.holder.attachBitmap(bmd, 1);
createGrid();
}
private function createGrid():Void
{
grid = new Array();
for(var y:Number = 0; y<this.height; y++)
{
grid[y] = new Array();
for(var x:Number = 0; x<this.width; x++)
{
//create a new point
var myPoint:Point3D = grid[y][x] = new Point3D();
//x and z depend on position (orientate around center
(0,0,0))
var xp:Number = x;
var zp:Number = y;
//y depends on the the greyscale value in percentage,
going from 'min' to 'max'
var pixel:Number = bmd.getPixel32(x, y);
trace("pixel = "+pixel);
trace("");
var percentage:Number = pixel / 0x000000;
var yp:Number = percentage * (max - min) + min;
myPoint.setPosition(xp, yp, zp);
}
}
}
The trace("pixel=..."); traces a negative value, which I find very
strange... Any suggestions ?
Greets,
Jeroen Beckers
[EMAIL PROTECTED]
http://www.dauntless.be
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com