Understanding AS3 ColorMatrixFilter class
2009-10-27 00:00:00 来源:WEB开发网 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.
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];
}
}
}
Tags:Understanding AS ColorMatrixFilter
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接