program Visual{

	var
	{
		integer s = 24;
		integer n = 32;
		integer i, j;
		float x ,y;
		float tx, ty;
		float k ,d;
		float[] a = new float[n];
		float len;
		integer width;
		integer height;
	}

	constructor
	{
		setFullScreenMode(true);
		setState(STATE_VGA);
		width = getWidth();
		height = getHeight();
	}

	function init():void;
	{
		if(width > height)
		{
			len = height / 2.0 / n;
		} 
		else
		{
			len = width / 2.0 / n;
		}
		k = random(360) * pi / 180.0;
		d = pi * 2.0 / s;
	}
	
	function update():void;
	{
		if(random(50) == 0)
		{
			k = random(360) * pi / 180.0;
		}
		a[0] = a[0] + sin(k) / 10.0;
		for(i = 1; i < n; i = i + 1)
		{
			a[i] = a[i] + (a[i - 1] - a[i]) * 0.1;
		}
		setColor(0, 0, 0);
		fillRect(0, 0, width, height);
		for(j = 0; j < s; j = j + 1)
		{
			x = 0.5 * width;
			y = 0.5 * height;
			for(i = 0; i < n; i = i + 1)
			{
				setColor(255- 5 * i / n ,0 , 255- 5 * i / n);
				tx = x + cos(j * d + a[i]) * len;
				ty = y + sin(j * d + a[i]) * len;
				drawLine(round(x), round(y), round(tx), round(ty));
				x = tx;
				y = ty;
			}
		}
	}

    function Main():void;
    {
		init();
		while(true)
		{
			update();
			repaint();
			sleep(10);
		}
    }
}