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

PerlinNoiseの引数と挙動

Get Adobe Flash player
by kuma360 25 Jul 2010
/**
 * Copyright kuma360 ( http://wonderfl.net/user/kuma360 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/QCX7
 */

package 
{
    import com.bit101.components.*;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.utils.getTimer;
    
    public class Main extends Sprite 
    {
        public function Main() { init() ; }
        
        //キャンバス
        private var _screen:BitmapData ;
        
        //画像用
        private var _img:BitmapData ;
        
        //GUI用
        private var _gui:GUI ;
        
        //描画の更新
        private var _last:Number ;
        
        public function init () :void {
            
            /////////////////////////////////////////////////////
            //キャンバス用意
            _screen = new BitmapData ( 465 , 465 , false , 0 ) ;
            addChild ( new Bitmap ( _screen ) ) ;
            
            _last = getTimer () ;
            
            
            /////////////////////////////////////////////////////
            //リソース用意
            _img = new BitmapData ( 465 , 465 , true , 0 ) ;
            
            _gui = new GUI ;
            addChild ( _gui ) ;
            
            /////////////////////////////////////////////////////
            addEventListener ( Event.ENTER_FRAME , run ) ;
            
        }
        
        
        public function run ( e:Event ):void {
            
            if ( getTimer() - _last > 1000 ) {
                
                _last = getTimer () ;
                
                _img.perlinNoise ( 
                    _gui.myHUISlider1.value ,
                    _gui.myHUISlider2.value ,
                    _gui.myHUISlider3.value ,
                    _gui.myHUISlider4.value ,
                    _gui.myCheckBox1.selected ,
                    _gui.myCheckBox2.selected ,
                    _gui.myHUISlider5.value ,
                    _gui.myCheckBox3.selected 
                ) ;
                
                _img.fillRect (
                    new Rectangle ( 0, 0, 200, 160 ) ,
                    0xFFFFFF
                ) ;
                
                _screen.fillRect ( _screen.rect , 0 ) ;
                _screen.copyPixels ( _img, _img.rect, new Point ) ;
            }
            
        }
        
    }
    
}




import com.bit101.components.*;
import flash.display.Sprite;

class GUI extends Sprite
{
    public  var myHUISlider1:HUISlider;
    public  var myHUISlider2:HUISlider;
    public  var myHUISlider3:HUISlider;
    public  var myHUISlider4:HUISlider;
    public  var myHUISlider5:HUISlider;
    public  var myHUISlider6:HUISlider;
    public  var myCheckBox1:CheckBox ;
    public  var myCheckBox2:CheckBox ;
    public  var myCheckBox3:CheckBox ;
    
    public function GUI()
    {
        myHUISlider1 = new HUISlider ( this, 0, 0,  "baseX" ) ;
        myHUISlider1.maximum = 200 ;
        myHUISlider1.value = 100 ;

        myHUISlider2 = new HUISlider ( this, 0, 20,  "baseY" ) ;
        myHUISlider2.maximum = 200 ;
        myHUISlider2.value = 100 ;
        
        myHUISlider3 = new HUISlider ( this, 0, 40,  "numOctaves" ) ;
        myHUISlider3.maximum = 10 ;
        myHUISlider3.value = 5 ;

        myHUISlider4 = new HUISlider ( this, 0, 60,  "randomSeed" ) ;
        myHUISlider4.maximum = 999 ;
        myHUISlider4.value = 5 ;

        myCheckBox1 = new CheckBox ( this, 0, 80, "Stich");

        myCheckBox2 = new CheckBox ( this, 0, 100, "Fractalnoise");
        myCheckBox2.selected = true ;
        
        myHUISlider5 = new HUISlider ( this, 0, 120,  "channelOptions" ) ;
        myHUISlider5.maximum = 15 ;
        myHUISlider5.value = 15 ;

        myCheckBox3 = new CheckBox ( this, 0, 140, "Gray");
        myCheckBox3.selected = true ;
        
    }    
}