In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Color Carve

From example 2-11, <Algorithms for Visual Design Using the Processing Language>, Kostas Terzidis
Get Adobe Flash player
by greentec 06 Jul 2016
/**
 * Copyright greentec ( http://wonderfl.net/user/greentec )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/CviU
 */

package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;
    import com.bit101.components.HSlider;
    import com.bit101.components.Label;
    
    public class FlashTest extends Sprite {
        
        public var index:int = 255;
        public var bmp:BitmapData;
        public var label:Label;
        
        public function FlashTest() {
            // write as3 code here..
            bmp = new BitmapData(465, 465, false, 0x0);
            
            
            
            draw();
            
            addChild(new Bitmap(bmp));
            var slider:HSlider = new HSlider(this, 10, 440, onChange);
            slider.width = 445;
            slider.minimum = 1;
            slider.maximum = 500;
            slider.value = 255;

            label = new Label(this, 10, 420, String(index));

        }
        
        public function onChange(e:Event):void
        {
            index = e.target.value;
            label.text = String(index);
            
            draw();
        }
        
        public function draw():void
        {
            var i:int;
            var j:int;
            
            var r:int;
            var g:int;
            var b:int;
            
            for (i = 0; i < 465; i+=1)
            {
                for (j = 0; j < 465; j+=1)
                {
                    r = int(index * 1.0 * Math.cos(Math.PI / 180 * i));
                    g = int(index * 1.0 * Math.sin(Math.PI / 180 * j));
                    b = r * g;
                    
                    r = Math.abs(r) % 255;
                    g = Math.abs(g) % 255;
                    b = Math.abs(b) % 255;
                    
                    bmp.setPixel(i, j, r << 16 | g << 8 | b)
                }
            }
        }
    }
}