开发学院图形图像Flash Understanding AS3 ColorMatrixFilter class 阅读

Understanding AS3 ColorMatrixFilter class

 2009-10-27 00:00:00 来源:WEB开发网   
核心提示: package{importflash.display.Sprite;publicclasscmfextendsSprite{varcats_image:cats=newcats();publicfunctioncmf(){addChild(cats_image);}}}nothing new&

 package {
 import flash.display.Sprite;
 public class cmf extends Sprite {
  var cats_image:cats=new cats();
  public function cmf() {
   addChild(cats_image);
  }
 }
}

nothing new… now it’s time to add the filter.

Now let’s try this script:

 package {
 import flash.display.Sprite;
 import flash.filters.ColorMatrixFilter;
 public class cmf extends Sprite {
  var cats_image:cats=new cats();
  public function cmf() {
   addChild(cats_image);
   var matrix:Array = new Array();
   matrix=matrix.concat([0.5,0.5,0.5,0,0]);// red
   matrix=matrix.concat([0.5,0.5,0.5,0,0]);// green
   matrix=matrix.concat([0.5,0.5,0.5,0,0]);// blue
   matrix=matrix.concat([0,0,0,1,0]);// alpha
   var my_filter:ColorMatrixFilter=new ColorMatrixFilter(matrix);
   cats_image.filters=[my_filter];
  }
 }
}

multiplying all values by 0.5, we have a standard (and not so interesting) black and white photo.

Understanding AS3 ColorMatrixFilter class

While with this script

 package {
 import flash.display.Sprite;
 import flash.filters.ColorMatrixFilter;
 public class cmf extends Sprite {
  var cats_image:cats=new cats();
  public function cmf() {
   addChild(cats_image);
   var matrix:Array = new Array();
   matrix=matrix.concat([1,0,0,0,0]);// red
   matrix=matrix.concat([0,1,0,0,0]);// green
   matrix=matrix.concat([0,0,1,0,0]);// blue
   matrix=matrix.concat([0,0,0,1,0]);// alpha
   var my_filter:ColorMatrixFilter=new ColorMatrixFilter(matrix);
   cats_image.filters=[my_filter];
  }
 }
}

上一页  1 2 3 4  下一页

Tags:Understanding AS ColorMatrixFilter

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接