运算公式:
redResult = a[0] * srcR + a[1] * srcG + a[2] * srcB + a[3] * srcA + a[4]
greenResult = a[5] * srcR + a[6] * srcG + a[7] * srcB + a[8] * srcA + a[9]
blueResult = a[10] * srcR + a[11] * srcG + a[12] * srcB + a[13] * srcA + a[14]
alphaResult = a[15] * srcR + a[16] * srcG + a[17] * srcB + a[18] * srcA + a[19]
红绿反色:
代码
var filterObj = new flash.filters.ColorMatrixFilter();
filterObj.matrix = new Array(
0,0,1,0,0,
0,1,0,0,0,
1,0,0,0,0,
0,0,0,1,0);
displayObject.filters = [filterObj];
filterObj.matrix = new Array(
0,0,1,0,0,
0,1,0,0,0,
1,0,0,0,0,
0,0,0,1,0);
displayObject.filters = [filterObj];
黑白:
代码
var filterObj = new flash.filters.ColorMatrixFilter();
filterObj.matrix = new Array(
1/3,1/3,1/3,0,0,
1/3,1/3,1/3,0,0,
1/3,1/3,1/3,0,0,
0, 0, 0,1,0);
displayObject.filters = [filterObj];
filterObj.matrix = new Array(
1/3,1/3,1/3,0,0,
1/3,1/3,1/3,0,0,
1/3,1/3,1/3,0,0,
0, 0, 0,1,0);
displayObject.filters = [filterObj];
旧照片:
代码
var filterObj = new flash.filters.ColorMatrixFilter();
filterObj.matrix = new Array(
1/2,1/2,1/2,0,0,
1/3,1/3,1/3,0,0,
1/4,1/4,1/4,0,0,
0, 0, 0,1,0);
displayObject.filters = [filterObj];
filterObj.matrix = new Array(
1/2,1/2,1/2,0,0,
1/3,1/3,1/3,0,0,
1/4,1/4,1/4,0,0,
0, 0, 0,1,0);
displayObject.filters = [filterObj];