flash on 2013-1-28

by Quasimondo
♥0 | Line 43 | Modified 2013-01-28 22:51:50 | MIT License
play

ActionScript3 source code

/**
 * Copyright Quasimondo ( http://wonderfl.net/user/Quasimondo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t4lu
 */

package {
    import flash.filters.ColorMatrixFilter;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    public class ColorMatrixFilterIssue extends Sprite {
        public function ColorMatrixFilterIssue() {
           test1()
           test2()
        }
        
        private function test1():void
        {
            var map:BitmapData  = new BitmapData(200,200,true,0);
            map.perlinNoise(100,100,3,12345,false,false,7,false);
            
            
            var cmf:ColorMatrixFilter = new ColorMatrixFilter([1.5,-0.2,0.03,0,-78,
                                                              -1.1,1.7,0.3,0,67,
                                                              0.2,1.7,1.7,0,90,
                                                              1.6,5.5,0.5,0,-597]);
                                                               
            map.applyFilter(map,map.rect,map.rect.topLeft,cmf);
            
            var result:BitmapData  = new BitmapData(200,200,true,0xff808080);
            
            result.draw(map);
            
            addChild( new Bitmap(result));
        }


        private function test2():void
        {
            var map:BitmapData  = new BitmapData(200,200,true,0);
            map.perlinNoise(100,100,3,12345,false,false,7,false);
            
            
            var cmf:ColorMatrixFilter = new ColorMatrixFilter([1,0,0,0,0,
                                                               0,1,0,0,0,
                                                               0,0,1,0,0,
                                                               1.6,5.5,0.5,0,-597]);
                                                               
            map.applyFilter(map,map.rect,map.rect.topLeft,cmf);
            
            cmf.matrix = [ 1.5,-0.2,0.03,0,-78,
                          -1.1,1.7,0.3,0,67,
                           0.2,1.7,1.7,0,90,
                           0,0,0,1,0];
            
            map.applyFilter(map,map.rect,map.rect.topLeft,cmf);
            
            var result:BitmapData  = new BitmapData(200,200,true,0xff808080);
            
            result.draw(map);
            
            addChild( new Bitmap(result)).x = 210;
        }
    }
}