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

Understanding AS3 ColorMatrixFilter class

 2009-10-27 00:00:00 来源:WEB开发网   
核心提示: package{importflash.display.Sprite;importflash.filters.ColorMatrixFilter;publicclasscmfextendsSprite{varcats_image:cats=newcats();publicfunctioncmf(

 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.5,0,0,0,-40]);// red
   matrix=matrix.concat([0,1.5,0,0,-40]);// green
   matrix=matrix.concat([0,0,1.5,0,-40]);// blue
   matrix=matrix.concat([0,0,0,1,0]);// alpha
   var my_filter:ColorMatrixFilter=new ColorMatrixFilter(matrix);
   cats_image.filters=[my_filter];
  }
 }
}

Understanding AS3 ColorMatrixFilter class

Changing the hue

To change the hue, swap red, green and blue values

 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,1,0,0,0]);// red
   matrix=matrix.concat([0,0,1,0,0]);// green
   matrix=matrix.concat([1,0,0,0,0]);// blue
   matrix=matrix.concat([0,0,0,1,0]);// alpha
   var my_filter:ColorMatrixFilter=new ColorMatrixFilter(matrix);
   cats_image.filters=[my_filter];
  }
 }
}

Understanding AS3 ColorMatrixFilter class

Obviously you must finetune your matrix in order to achieve the best effect, but now you know how to change colors on the fly.

本文示例源代码或素材下载

上一页  1 2 3 4 

Tags:Understanding AS ColorMatrixFilter

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接