AS2类:颜色属性ColorProperty(饱和度对比度等)
用AS来调整图片的色相、亮度、灰度、饱和度、对比度、反相虽然不难,但因为涉及到ColorMatrixFilter的颜色矩阵的应用,使用起来有点麻烦,因此写了这个类ColorProperty。
这个类是对MovieClip类扩展,为MovieClip增加了这些属性:色相:_hue,亮度:_brightness,灰度:_grayscale,饱和度:_saturation,对比度:_contrast,反相:_invert。
当然,你也可以改写这个类,使之成为一个新类,而不是扩展MovieClip类。
用法(与_width,_height用法一样):
import ColorProperty;
ColorProperty.init();
//色相,取值范围为:-180~180
//img._hue=100;
//trace(img._hue);
//亮度,取值范围为:-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;
附上源文件和演示:点击下载ColorProperty