Dart Documentation › stagexl › GlowFilter

GlowFilter class

class GlowFilter extends BitmapFilter {

 int color;
 num alpha;
 int blurX;
 int blurY;
 bool knockout;
 bool hideObject;

 GlowFilter(this.color, this.alpha, this.blurX, this.blurY, {
            this.knockout: false, this.hideObject: false}) {

   if (blurX < 1 || blurY < 1) {
     throw new ArgumentError("Error #9004: The minimum blur size is 1.");
   }
   if (blurX > 64 || blurY > 64) {
     throw new ArgumentError("Error #9004: The maximum blur size is 64.");
   }
 }

 BitmapFilter clone() => new GlowFilter(color, alpha, blurX, blurY,
     knockout: knockout, hideObject: hideObject);

 Rectangle get overlap => new Rectangle(-blurX, -blurY, 2 * blurX, 2 * blurY);

 //-------------------------------------------------------------------------------------------------
 //-------------------------------------------------------------------------------------------------

 void apply(BitmapData bitmapData, [Rectangle rectangle]) {

   RenderTextureQuad renderTextureQuad = rectangle == null
       ? bitmapData.renderTextureQuad
       : bitmapData.renderTextureQuad.cut(rectangle);

   ImageData sourceImageData =
       this.hideObject == false || this.knockout ? renderTextureQuad.getImageData() : null;

   ImageData imageData = renderTextureQuad.getImageData();
   List<int> data = imageData.data;
   int width = _ensureInt(imageData.width);
   int height = _ensureInt(imageData.height);

   num pixelRatio = renderTextureQuad.renderTexture.storePixelRatio;
   int blurX = (this.blurX * pixelRatio).round();
   int blurY = (this.blurY * pixelRatio).round();
   int alphaChannel = _isLittleEndianSystem ? 3 : 0;
   int stride = width * 4;

   for (int x = 0; x < width; x++) {
     _blur2(data, x * 4 + alphaChannel, height, stride, blurY);
   }

   for (int y = 0; y < height; y++) {
     _blur2(data, y * stride + alphaChannel, width, 4, blurX);
   }

   if (this.knockout) {
     _setColorKnockout(data, this.color, this.alpha, sourceImageData.data);
   } else if (this.hideObject) {
     _setColor(data, this.color, this.alpha);
   } else {
     _setColorBlend(data, this.color, this.alpha, sourceImageData.data);
   }

   renderTextureQuad.putImageData(imageData);
 }


}

Extends

BitmapFilter > GlowFilter

Constructors

new GlowFilter(int color, num alpha, int blurX, int blurY, {bool knockout: false, bool hideObject: false}) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
GlowFilter(this.color, this.alpha, this.blurX, this.blurY, {
          this.knockout: false, this.hideObject: false}) {

 if (blurX < 1 || blurY < 1) {
   throw new ArgumentError("Error #9004: The minimum blur size is 1.");
 }
 if (blurX > 64 || blurY > 64) {
   throw new ArgumentError("Error #9004: The maximum blur size is 64.");
 }
}

Properties

num alpha #

num alpha

int blurX #

int blurX

int blurY #

int blurY

int color #

int color

bool hideObject #

bool hideObject

bool knockout #

bool knockout

final Rectangle overlap #

Rectangle get overlap => new Rectangle(-blurX, -blurY, 2 * blurX, 2 * blurY);

Methods

void apply(BitmapData bitmapData, [Rectangle rectangle]) #

void apply(BitmapData bitmapData, [Rectangle rectangle]) {

 RenderTextureQuad renderTextureQuad = rectangle == null
     ? bitmapData.renderTextureQuad
     : bitmapData.renderTextureQuad.cut(rectangle);

 ImageData sourceImageData =
     this.hideObject == false || this.knockout ? renderTextureQuad.getImageData() : null;

 ImageData imageData = renderTextureQuad.getImageData();
 List<int> data = imageData.data;
 int width = _ensureInt(imageData.width);
 int height = _ensureInt(imageData.height);

 num pixelRatio = renderTextureQuad.renderTexture.storePixelRatio;
 int blurX = (this.blurX * pixelRatio).round();
 int blurY = (this.blurY * pixelRatio).round();
 int alphaChannel = _isLittleEndianSystem ? 3 : 0;
 int stride = width * 4;

 for (int x = 0; x < width; x++) {
   _blur2(data, x * 4 + alphaChannel, height, stride, blurY);
 }

 for (int y = 0; y < height; y++) {
   _blur2(data, y * stride + alphaChannel, width, 4, blurX);
 }

 if (this.knockout) {
   _setColorKnockout(data, this.color, this.alpha, sourceImageData.data);
 } else if (this.hideObject) {
   _setColor(data, this.color, this.alpha);
 } else {
   _setColorBlend(data, this.color, this.alpha, sourceImageData.data);
 }

 renderTextureQuad.putImageData(imageData);
}

BitmapFilter clone() #

BitmapFilter clone() => new GlowFilter(color, alpha, blurX, blurY,
   knockout: knockout, hideObject: hideObject);