forked from: Wave
Frocessingで書き直し。
/**
* Copyright osamX ( http://wonderfl.net/user/osamX )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/maWx
*/
// forked from osamX's Wave
// Frocessingで書き直し。
package
{
import flash.geom.Point;
import frocessing.display.F5MovieClip2D;
[SWF(width=465, height=465, backgroundColor=0x000000, frameRate=30)]
public class Main extends F5MovieClip2D
{
private const SIZE:Number = 50;
private const NUM:uint = 10;
private const PI:Number = Math.PI;
private var mouseP:Point;
private var r:Number = 0;
public function setup():void
{
mouseP = new Point();
background(0);
}
public function draw():void {
background(0);
mouseP.x += (stage.mouseX - mouseP.x) / 5;
mouseP.y += (stage.mouseY - mouseP.y) / 5;
r = (r + 6) % 360;
var offsetY:Number = 465/2-NUM/2, radian:Number, color:uint, dif:Number,
lastP:Point = new Point(), currentP:Point = new Point();
for (var yy:int = 0; yy < NUM; yy++) {
radian = (5 * yy + r) % 360;
for (var xx:int = 0; xx < 465; xx++) {
currentP.x = xx;
currentP.y = SIZE * Math.sin(PI*radian/180) + yy + offsetY;
if(xx){
dif = Math.abs( Math.atan((465/2-mouseP.y)/(465/2-mouseP.x)) - Math.atan((currentP.y-lastP.y)/(currentP.x-lastP.x)) );
if (dif > PI / 2) dif = PI - dif;
color = 0xFF*dif/(PI/2);
stroke(color, color, color);
line(lastP.x, lastP.y, currentP.x, currentP.y);
}
lastP.x = currentP.x;
lastP.y = currentP.y;
radian = (radian + 1) % 360;
}
}
line(465 / 2, 465 / 2, mouseP.x, mouseP.y);
}
}
}