February 13, 2008 at 5:13 am
· Filed under Sandy3d, 3d, Graphics, BitmapData, Papervision3d, AS3
Uff… long time I don’t write here…
So… what I have been doing?
Actually… nothing interesting…
Then, couple days ago I started developing my own 3d engine.
I won’t make it public because it will take all my free time that I actually don’t have…
I didn’t run any benchmarks, I think it’s more heavy processing than Papervision3d.
anyway… here is it…
Permalink
January 24, 2008 at 2:52 am
· Filed under Graphics, source, BitmapData, AS3
It’s a gradient created from the corners of the square.
I was googling and I found the Diamond-Square on Wikipedia.
The idea is quite simple.
First you get the top left and bottom left corner colors of the square. Than, you get the half height of the edge and also the average color of those colors.
You repeat that until you have all pixels of the edge.
Note: The average color is not (color2 - color1) * .5.
It’s (color2.r - color1.r) * .5 << 16 + (color2.g - color1.g) * .5 << 8 + (color2.b - color1.b) * .5.
After that, you make the same with the right edge.
Than, you do it for each edge from the top to bottom.
If you work around more, you can create gradient spots from any pixel you wish easily.
Permalink
January 19, 2008 at 3:00 am
· Filed under Graphics, source, BitmapData, AS3
Answering to CK
1.
ck said,
January 14, 2008 @ 8:07 pm · Edit
… you mentioned to use BitmapData.paletteMap() to generate a grayscale image. Until now I didn’t get this working. How did you do that?
You can convert a BitmapData to Grayscale easily without using my ColorUtils class.
import br.
hellokeita.
utils.
ColorUtils;
…
var bmpData:BitmapData = new BitmapData(w, h);
…
var grayscaleArray:Array = new Array();
var c:Number;
for(var i = 0; i < 0xff; i++){
c = i * .3 + i * .59 + i * .11;
grayscaleArray[i] = (c<<16) + (c<<8) + c;
}
bmpData.paletteMap(bmpData, bmpData.rect, new Point(0,0), grayscaleArray, grayscaleArray, grayscaleArray);
Permalink
November 8, 2007 at 1:12 am
· Filed under Benchmark, Graphics, BitmapData, Performance, AS3
Firstly… sorry for my poor English…
Working on Recyou.jp, I had to use many BitmapDatas, and so, I had to work out some way to make it lighter.
One thing I realized is that using Graphics.beginBitmapFill besides BitmapData.draw its much faster.
I made the benchmarks, drawing 10000 bitmapDatas, one using BitmapData.draw, and other using Graphics.beginBitmapFill.
First the benchmark with BitmapData.draw (Clicking on the flash it will re-run the benchmark):
The code is something like this:
var genericBmp:BitmapData = new BitmapData(100,100, false, 0×000000);
var bmp:BitmapData = new BitmapData(100,100, false, 0×000000);
for(var i = 0; i < 10000; i++){
bmp.draw(genericBmp);
}
Now the benchmark with Graphics.beginBitmapFill (Clicking on the flash it will re-run the benchmark):
The code is something like this:
var genericBmp:BitmapData = new BitmapData(100,100, false, 0×000000);
var bmp:BitmapData = new BitmapData(100,100, false, 0×000000);
for(var i = 0; i < 10000; i++){
graphics.beginBitmapFill(genericBmp);
graphics.drawRect(0,0,100,100);
}
So, if you are trying to create some bitmap pattens or attaching a Bitmap child and redrawing it’s BitmapData, try using the Graphics.beginBitmapFill.
Permalink