forked from: PaintSample
see http://gihyo.jp/design/feature/01/frocessing/0003
/**
* Copyright nutsu ( http://wonderfl.net/user/nutsu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6ypy
*/
// forked from nutsu's PaintSample
// see http://gihyo.jp/design/feature/01/frocessing/0003
package {
import frocessing.display.F5MovieClip2DBmp;
[SWF(width=465,height=465,backgroundColor=0x000000)]
public class PaintSample2 extends F5MovieClip2DBmp
{
public function setup():void
{
//キャンバスのサイズ指定
size( 465, 465 );
//背景の描画
background( 0 );
//色指定
stroke( 0, 0.2 );
//HSV
colorMode( HSV, 1 );
}
public function draw():void
{
//マウスが押されているときは描画内容をクリア
if ( isMousePressed )
background( 0 );
//dist()で2点間の距離を取得
var d:Number = dist( pmouseX, pmouseY, mouseX, mouseY );
if ( d < 3 )
return;
//中点
var x1:Number = (pmouseX+mouseX)/2;
var y1:Number = (pmouseY+mouseY)/2;
//中点の周辺にランダムな円を描画
d /= 2;
for ( var i:int = 0; i < int(d); i++ ) {
var xx:Number = x1 + random( -d, d );
var yy:Number = y1 + random( -d, d );
fill( random(0.95, 1), random(0.5, 1), random(0.5, 1) );
circle( xx, yy, random(1, d/3) );
}
}
}
}