lundi 28 septembre 2015

TweenLite/TweenMax support for ConvolutionFilter

I am applying filters to a bitmap using something like:,0,{colorMatrixFilter:{saturation:2,brightness:3});

and that works fine.

I need to somehow apply a sharpen filter to origBitmap which I have successfully achieved using a ConvolutionFilter. The problem is after I've ran the above tweenlite call, then create a convolution filter and apply it to origBitmap, it removes the initial saturation and brightness filters and just keeps the sharpen filter

private function applyEffects(effects:Array):void
  currentEffects = effects;
  var props:Object = {};
  for (var i:String in effects)
    props[effects[i].effect] = effects[i].amount;
  //-- props could look like {saturation:2,brightness:3}

  //-- This will sharpen the container sprite
  var matrix:Array = [0, -1,  0,
                     -1,  5, -1,
                      0, -1,  0];
  var conv:ConvolutionFilter = new ConvolutionFilter();
  conv.matrixX = 3;
  conv.matrixY = 3;
  conv.matrix = matrix;
  conv.divisor = 1; 
  bitmap.filters = [conv]; //-- this removes the above filters and just sharpens the image

Is there a way to also incorporate the ConvolutionFilter in that TweenLite call above? I've searched quite a bit and found some guy made a class called TweenMan which was based around your class where ConvolutionFilter is incorporated:

Aucun commentaire:

Enregistrer un commentaire