[ 来源:www.it55.com | 作者: | 时间:2007-07-12 | 收藏 | 推荐 ] 【大 中 小】
用AS来调整图片的色调、亮度、灰度、饱和度、对比度、反相虽然不难,但因为涉及到ColorMatrixFilter的颜色矩阵的应用,使用起来有点麻烦,因此写了这个类ColorProperty。 it55.com
这个类是对MovieClip类扩展,为MovieClip增加了这些属性: sflj www.it55.com kg^&fgd
当然,你也可以改写这个类,使之成为一个新类,而不是扩展MovieClip类。 45398 www.it55.com it55学习IT知识,享受IT生活 4dfkjn
用法(与_width,_height用法一样):
www.it55.com在线教程
import ColorProperty;
ColorProperty.init();
//色调,用如0xFF0000的16进制
//img._color=0x333399;
//trace(img._color);
//亮度,取值范围为:-255~255
img._brightness = 100;
//trace(img._brightness)
//灰度,布尔值,true为灰度,false则反之。
//img._grayscale = true;
//trace(img._grayscale);
//饱和度,一般范围为:0~3为宜
//img._saturation = 3;
//trace(img._saturation);
//对比度,取值范围为:0~1
//img._contrast = 0.15;
//反相,布尔值,true为反相,false则反之。
//trace(img._contrast);
//img._invert=true;
vd;k;l www.it55.com rdfg
代码如下:
/**
* @Name:ColorProperty(MovieClip颜色属性)
* 色调:_color,亮度:_brightness,灰度:_grayscale,饱和度:_saturation,对比度:_contrast,反相:_invert
* @author:Flashlizi
* @version:1.0
*/
import flash.filters.ColorMatrixFilter;
class ColorProperty
{
//_matrix是ColorMatrixFilter类的默认恒等矩阵
//_nRed,_nGreen,_nBlue是计算机图形颜色亮度的常量
//private static var _matrix : Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
private static var _nRed : Number = 0.3086;
private static var _nGreen : Number = 0.6094;
private static var _nBlue : Number = 0.0820;
function ColorProperty ()
{
}
public static function init ()
{
setColorProperty ();
//色调Color
www.it55.com
(阅读次数:)