, Sr. Member
I wrote down a function that could go well with the particle system.
I call it GradientBitmapMaterialConstructor.
The main idea is that you throw at it a black’n'white picture(bitmap data) and enter 2 colors for the lowest and highest color and it returns for you a bitmap data that you can use as material. It will be more clear when you see the attachment.
The construction of the class is the following:
Construct(bitmap_base:BitmapData, high_color:uint, low_color:uint, alpha_ease:Boolean = true, alphaTreshold:Number = 0.25)
- bitmap_base is the bitmap data of the black’n'white gradient picture.
- high_color is the color that will replace the whitest color in the bitmap.
- low_color is the color that will replace the darkest color in the bitmap above 0. Pure black color (0,0,0) will be transparent. The colors between them will be transforming from one to another.
- alpha_ease if set to true will make the colors included in the threshold fade away with alpha(transparency). default is 1/4, so if the highest color is 255,255,255 and the lowest is 1,1,1 colors below 63,63,63 till 1,1,1 will fade away in transparency.
- alphaTreshold should be decimal from 0 to 1. Default is 0.25 which is 1/4. If you want the transparency fading to start right from the highest color it should be 1. This works only if alpha_ease is true.
Now the example in the attachment:
1. First picture is the main input bitmap that is used for construction.
2. Second picture is without alpha fading (alpha_ease is set to false)
material_constructor.Construct(new BasicMaterial().bitmapData, 0xffcc00, 0xff3600, false);
3. Third picture is same colors as second but with alpha fading using the default 0.25 threshold.
material_constructor.Construct(new BasicMaterial().bitmapData, 0xffcc00, 0xff3600, true);
4.5. Forth and fifth picture is same settings as third with different colors.
material_constructor.Construct(new BasicMaterial().bitmapData, 0xdadffa, 0x24399b, true);
material_constructor.Construct(new BasicMaterial().bitmapData, 0x42ff00, 0xff00a8, true);
6. Sixth is same like third but with 0.9 threshold which means transparent fading starts almost right away.
material_constructor.Construct(new BasicMaterial().bitmapData, 0xffcc00, 0xff3600, true, 0.9);
With this function you can make many different materials with the same basic picture and if you decide to tweak the colors its as simple as changing two values.