topical media & game development
#graphic-flex-image-effects-07-source-aether-textures-natural-StarsTexture.ax
#graphic-flex-image-effects-07-source-aether-textures-natural-StarsTexture.ax
[swf]
[flash]
flex
package aether.textures.natural {
import aether.textures.ITexture;
import aether.utils.Adjustments;
import aether.utils.ImageUtil;
import aether.utils.MathUtil;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.filters.BlurFilter;
public class @ax-graphic-flex-image-effects-07-source-aether-textures-natural-StarsTexture implements ITexture {
private var _density:Number;
private var _width:Number;
private var _height:Number;
public function @ax-graphic-flex-image-effects-07-source-aether-textures-natural-StarsTexture(width:Number, height:Number, density:Number=.5) {
_density = MathUtil.clamp(density, 0, 1);
_width = width;
_height = height;
}
public function draw():BitmapData {
var noise:BitmapData = new BitmapData(_width, _height, false);
var perlin:BitmapData = noise.clone();
noise.noise(int(new Date()), 0, 255, 7, true);
ImageUtil.applyFilter(noise, new BlurFilter(2, 2));
var black:uint = 160 - 80*_density;
var mid:uint = (200 - black)/2 + black;
Adjustments.setLevels(noise, black, mid, 200);
perlin.perlinNoise(50, 50, 2, Math.random(), false, true, 7, true);
noise.draw(perlin, null, null, BlendMode.MULTIPLY);
perlin.dispose();
return noise;
}
}
}
(C) Æliens
04/09/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.