forked from: 辺がぼよよんってなる四角 3
花っぽいのも一応作れる
// forked from a24's 辺がぼよよんってなる四角
// 花っぽいのも一応作れる
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
[ SWF( width = "465" , height = "465" , backgroundColor = "0xFFFFFF" , frameRate = "60" ) ]
public class Main extends Sprite
{
public function Main()
{
stage.addEventListener( MouseEvent.MOUSE_MOVE , create );
}
private function create( e:MouseEvent ):void
{
var _color:uint = Math.random() * 0xFFFF00;
var _cr:CurveRect = new CurveRect();
_cr.rotation = Math.random() * 45;
_cr.alpha = 1;
_cr.x = stage.mouseX;
_cr.y = stage.mouseY;
_cr.scaleX = _cr.scaleY = 0.2 + Math.random() * 1.5;
_cr.lineStyle( 1.0 , 0xFFFFFF , 0 );
_cr.beginFill( _color , 1.0 );
_cr._width = 20;
_cr._height = 20;
_cr._round = 0; // 角丸値
_cr._curve = -18; // 辺のカーブ値
_cr.draw( true ); //基準点をセンターで描画
var _cr2:CurveRect = new CurveRect();
_cr2.rotation = 45;
_cr2.scaleX = _cr2.scaleY = 1;
_cr2.lineStyle( 1.0 , 0xFFFFFF , 0 );
_cr2.beginFill( _color , 1.0 );
_cr2._width = 20;
_cr2._height = 20;
_cr2._round = 0; // 角丸値
_cr2._curve = -18; // 辺のカーブ値
_cr2.draw( true ); //基準点をセンターで描画
_cr.addChild( _cr2 );
addChild( _cr );
Tweener.addTween( _cr , {
x:( _cr.x - 50 ) + Math.random() * 100 ,
y:( _cr.y - 50 ) + Math.random() * 100 ,
alpha:0 ,
rotation:Math.random() * 180 ,
time:2 ,
onComplete:function():void{ removeChild( _cr ); }
} );
}
}
}
import flash.display.Sprite;
import flash.display.Graphics;
class CurveRect extends Sprite
{
private var _g:Graphics;
private var _lineStyle:Array;
private var _beginFill:Array;
public var _round:Number;
public var _curve:Number;
public var _width:Number;
public var _height:Number;
public function CurveRect()
{
_g = this.graphics;
_lineStyle = [ 1 , 0x000000 , 1.0 ];
_beginFill = [ 0xFFFFFF , 1.0 ];
_round = 0;
_curve = 0;
}
public function lineStyle( _thickness:Number , _color:uint , _alpha:Number ):void
{
_lineStyle = [ _thickness , _color , _alpha ];
}
public function beginFill( _color:uint , _alpha:Number ):void
{
_beginFill = [ _color , _alpha ];
}
public function draw( _center:Boolean = false ):void
{
var _posX:Number = ( _center ) ? _width/2 : 0;
var _posY:Number = ( _center ) ? _height/2 : 0;
_g.clear();
_g.lineStyle( _lineStyle[0] , _lineStyle[1] , _lineStyle[2] );
_g.beginFill ( _beginFill[0] , _beginFill[1] );
_g.moveTo ( 0 - _posX , _round - _posY );
_g.curveTo ( 0 - _posX , 0 - _posY , _round - _posX , 0 -_posY );
_g.curveTo ( _width/2 - _posX , -_curve - _posY , _width -_round - _posX , 0 - _posY );
_g.curveTo ( _width - _posX , 0 - _posY , _width - _posX , _round - _posY );
_g.curveTo ( _width + _curve - _posX , _height/2 - _posY , _width - _posX , _height -_round - _posY );
_g.curveTo ( _width - _posX , _height - _posY , _width - _round - _posX , _height - _posY );
_g.curveTo ( _width/2 - _posX , _height + _curve - _posY , _round - _posX , _height - _posY );
_g.curveTo ( 0 - _posX , _height - _posY , 0 - _posX , _height - _round - _posY );
_g.curveTo ( -_curve - _posX , _height/2 - _posY , 0 - _posX , _round - _posY );
_g.endFill();
}
}