8の字〜

Source (JavaScript)

// 定数
a = 10; // 横方向移動量
b = 0.5; // 勾配
yoko = 150; //x方向表示位置
tate = 150; //y方向表示位置

// 変数
x = 0;
direction = "inc";

function letterEight() {

	if (direction == "inc") {
		if ((x >= 0) && (x <= a*2)) {
			y = b * (Math.pow((x-a),2) - Math.pow(a,2));
		}
		else if ((x < 0) && (x >= 0 - a*2)) {
			y = b * (0 - Math.pow((x+a),2) + Math.pow(a,2));
		}
	}
	else if (direction == "dec") {
		if ((x >= 0) && (x <= a*2)) {
			y = b * (0 - Math.pow((x-a),2) + Math.pow(a,2));
		}
		else if ((x < 0) && (x >= 0 - a*2)) {
			y = b * (Math.pow((x+a),2) - Math.pow(a,2));
		}
	}

	if (document.all) {
		document.all["test"].style.left = yoko + x + "px";
		document.all["test"].style.top  = tate - y + "px";
	}
	else if (!document.all && document.getElementById) {
		document.getElementById("test").style.left = yoko + x + "px";
		document.getElementById("test").style.top  = tate - y + "px";
	}

	if (direction == "inc") {
		if (x < a*2) x++;
		else { direction = "dec"; x-=1; }
	}
	else if (direction == "dec") {
		if (x > 0-a*2) x--;
		else { direction = "inc"; x+=1; }
	}

	setTimeout('letterEight()',20);

}

Source (HTML)

<div id=test style="position:absolute;">8の字〜</div>

Hints: