관리 메뉴

180bpm

틴트 먹이는 메서드 본문

Flash/기타

틴트 먹이는 메서드

powdersnow 2012. 7. 16. 14:37
반응형


//code start


private static var r_lum:Number = 0.212671; private static var g_lum:Number = 0.715160; private static var b_lum:Number = 0.072169;


/** * 틴트 먹이는 메서드 - 4.0.15에서 filters 를 지원 안 함. * RGB to Luminance conversion constants as found on * Charles A. Poynton's colorspace-faq: * http://www.faqs.org/faqs/graphics/colorspace-faq/ * @param rgb * @param amount * @see http://developer.longtailvideo.com/trac/browser/trunk/as3/com/anttikupila/revolt/effects/Tint.as?rev=161 * @return */ private function tint(rgb:Number, amount:Number):Array { var r:Number = ( ( rgb >> 16 ) & 0xff ) / 255; var g:Number = ( ( rgb >> 8 ) & 0xff ) / 255; var b:Number = ( rgb & 0xff ) / 255; var colorMatrix:Array; var filter:ColorMatrixFilter; if (amount==0 ) { colorMatrix = [ 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]; filter = new ColorMatrixFilter(colorMatrix); this.filters = [filter]; return; } if (!amount) amount = 1; var inv_amount:Number = 1 - amount; colorMatrix = [ inv_amount + amount*r*r_lum, amount*r*g_lum, amount*r*b_lum, 0, 0, amount*g*r_lum, inv_amount + amount*g*g_lum, amount*g*b_lum, 0, 0, amount*b*r_lum,amount*b*g_lum, inv_amount + amount*b*b_lum, 0, 0, 0 , 0 , 0 , 1, 0]; filter = new ColorMatrixFilter(colorMatrix); this.filters = [filter]; return colorMatrix; } //code end


반응형
Comments