Understanding AS3 ColorMatrixFilter class
2009-10-27 00:00:00 来源:WEB开发网 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];
}
}
}
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];
}
}
}
Obviously you must finetune your matrix in order to achieve the best effect, but now you know how to change colors on the fly.
本文示例源代码或素材下载
Tags:Understanding AS ColorMatrixFilter
编辑录入:爽爽 [复制链接] [打 印]- ››ASP.NET及JS中的cookie基本用法
- ››ASP.NET获取MS SQL Server安装实例
- ››asp.net实现调用百度pai 在线翻译英文转中文
- ››ASP.NET页面选项进行提示判断
- ››Asp.net定时执行程序
- ››ASP.NET中利用DataList实现图片无缝滚动
- ››ASP.NET验证控件RequiredFieldValidator
- ››ASP.NET中使用System.Net.Mail发邮件
- ››ASP.NET中获取用户控件中控件的ID
- ››ASP.NET中FileBytes写成文件并存档
- ››asp获取毫秒数
- ››asp.net报“INSERT INTO 语句的语法错误解决
更多精彩
赞助商链接