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

drawCircle Art

画面クリックで再描画です
円同士が接するようにいっぱい描きます
beginFillがぐちゃぐちゃになるのでアートを気取れます
Get Adobe Flash player
by undo 01 Mar 2011
  • Related works: 2
  • Talk

    undo at 01 Mar 2011 09:59
    そもそもやりたかったのはこれ http://www.mw-company.com/
    soundkitchen at 01 Mar 2011 10:45
    なんとなく、それっぽいですねw
    Embed
package {
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.ui.Keyboard;
    
    public class FlashTest extends Sprite {
        private var _canvas1:Sprite;
        private var _canvas2:Sprite;
        
        private var _thickness1:Number = 10;
        private var _thickness2:Number = 3;
        
        private var _lineColor1:uint = 0xffffff;
        private var _lineColor2:uint = 0x0;
        
        private var _fillColor:uint = 0xcc0000;
        
        private var _maxRadius:Number = 100;
        private var _minRadius:Number = 10;
        private var _maxRadian:Number = 540;
        private var _minRadian:Number = 90;
        
        public function FlashTest() {
            _canvas1 = addChild(new Sprite()) as Sprite;
            _canvas2 = addChild(new Sprite()) as Sprite;
            
            draw();
            
            stage.addEventListener(MouseEvent.CLICK, onClick);
        }
        private function onClick(evt:MouseEvent):void
        {
            draw();
        }
        private function draw(cycles:int = 10, width:Number = 465, height:Number = 465):void
        {
            var g1:Graphics = _canvas1.graphics;
            var g2:Graphics = _canvas2.graphics;
            g1.clear();
            g2.clear();
            
            g1.lineStyle(_thickness1,_lineColor1);
            g2.lineStyle(_thickness2,_lineColor2);
            g1.beginFill(_fillColor);
            var center:Point;
            var radius:Number;
            var omega:Number;
            var radian:Number = 0;
            for(var i:int = 0; i < cycles; i++)
            {
                omega = (Math.random()*(_maxRadian - _minRadian) + _minRadian)*Math.PI/180;
                if(Math.random()>=0.5)omega=-omega;
                if(!center)
                {
                    center = new Point(Math.random()*width, Math.random()*height);
                    radius = Math.random()*(_maxRadius - _minRadius) + _minRadius;
                }
                else
                {
                    var newRadius:Number = Math.random()*(_maxRadius - _minRadius) + _minRadius;
                    if(Math.random()>=0.8)//どちらかというと外側にいってほしいので
                    {
                        newRadius = -newRadius;
                    }
                    var newCenter:Point = new Point();
                    center.x += Math.cos(radian)*(radius+newRadius);
                    center.y += Math.sin(radian)*(radius+newRadius);
                    radius = Math.abs(newRadius);
                    if(newRadius >= 0)
                    {
                        radian += Math.PI;
                    }
                }
                
                g1.moveTo(center.x + Math.cos(radian)*radius, center.y + Math.sin(radian)*radius);
                g2.moveTo(center.x + Math.cos(radian)*radius, center.y + Math.sin(radian)*radius);
                
                if(omega>0)
                {
                    while(omega>0)
                    {
                        omega -= 0.1;
                        radian += 0.1;
                        g1.lineTo(center.x + Math.cos(radian)*radius, center.y + Math.sin(radian)*radius);
                        g2.lineTo(center.x + Math.cos(radian)*radius, center.y + Math.sin(radian)*radius);
                    }
                }
                else
                {
                    while(omega<0)
                    {
                        omega += 0.1;
                        radian -= 0.1;
                        g1.lineTo(center.x + Math.cos(radian)*radius, center.y + Math.sin(radian)*radius);
                        g2.lineTo(center.x + Math.cos(radian)*radius, center.y + Math.sin(radian)*radius);
                    }
                }
            }
            
            g1.endFill();
            g2.endFill();
        }
    }
}