forked from: 辺がぼよよんってなる四角 1
_curveの値をマイナスにするとキラキラっぽくなる
ちょっとでかいけど。。
// forked from a24's 辺がぼよよんってなる四角
// _curveの値をマイナスにするとキラキラっぽくなる
// ちょっとでかいけど。。
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.filters.GlowFilter;
import caurina.transitions.Tweener;
[ SWF( width = "465" , height = "465" , backgroundColor = "0x000000" , frameRate = "60" ) ]
public class Main extends Sprite
{
public function Main()
{
stage.addEventListener( MouseEvent.MOUSE_MOVE , create );
}
private function create( e:MouseEvent ):void
{
var _cr:CurveRect = new CurveRect();
_cr.alpha = 0.5 + Math.random() * 0.5;
_cr.x = stage.mouseX;
_cr.y = stage.mouseY;
_cr.scaleX = _cr.scaleY = 0.2 + Math.random() * 0.8;
_cr.lineStyle( 1.0 , 0xFFFFFF , 0 );
_cr.beginFill( 0xFFFFFF , 1.0 );
_cr._width = 14;
_cr._height = 14;
_cr._round = 0; // 角丸値
_cr._curve = -7; // 辺のカーブ値
_cr.draw( true ); //基準点をセンターで描画
_cr.filters = [ new GlowFilter( 0xFFFFFF , 0.8 , 16 , 16 , 1.5 ) ];
addChild( _cr );
Tweener.addTween( _cr , {
y:_cr.y + 200 * Math.random() ,
alpha:0 ,
rotation:Math.random() * 360 + 180 ,
time:Math.random() + 0.2 ,
transition:"easeInQuad" ,
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();
}
}