﻿			var zureX = -200;
            var zureY = -110;
			var a = 0;
			var oldX = 0;
			var oldY = 0;
			var mousehand = false;
			// マウスの座標を取得
			function mouseCheck(evt) {
				var mouseX = (Event.pointerX(evt) + zureX);
				var mouseY = (Event.pointerY(evt) + zureY);
				//if (evt.shiftKey == true) drawLine(oldX, oldY, mouseX, mouseY);
				if (mousehand == true) drawLine(oldX, oldY, mouseX, mouseY);
				oldX = mouseX;
				oldY = mouseY;
			}
			// 線を描画　??01（ここから）
			function drawLine(x1, y1, x2, y2){
				context.beginPath();	//　??02
				context.moveTo(x1,y1);	//　??03
				context.lineTo(x2,y2);	//　??04
				context.closePath();	//　??05
				context.stroke();	//　??06
			}
			// 線を描画　??01（ここまで）
			
			// 色を設定
			function setStrokeStyle(R,G,B){
				a = eval(document.getElementById("stOpac").value);
				context.lineWidth = eval(document.getElementById("stWidth").value);
				context.strokeStyle = "rgba("+R+","+G+","+B+","+a+")";
			}
			// 文字を描画 (Firefox 3のみ)　??07（ここから）
			function textDraw(txt){
				context.save();	// 現在の状態を保存　??10
				var X = Math.floor(Math.random() * 500)+50;
				var Y = Math.floor(Math.random() * 400)+50;
				context.fillStyle = "rgba(0,0,0,1)";	// 黒色にする
				context.mozTextStyle = "48pt bold sans serif";	//　??08
				context.translate(X,Y);
				context.mozDrawText(txt);	//　??09
				context.restore();	// 以前の状態を復活　??10
			}
			//　??07（ここまで）
			
			// canvas内容を初期化
			window.onload = function() {
				Event.observe(document.body, "mousemove",mouseCheck, false);
				var canvasObj = document.getElementById("plotArea");
				context = canvasObj.getContext("2d");
				context.fillStyle = "rgba(255,255,255,1)";	// 白色にする
				context.fillRect(0,0,800,600);	// キャンバスを消去
				context.strokeStyle = "rgba(255, 0, 0, 1)";
				context.lineJoin = "round";
				document.getElementById("drawCanvasText").onclick = function(){
					var txt = document.getElementById("aText").value;
						textDraw(txt);
				}
				//前消し
				document.getElementById("clear").onclick = function(){
				context.fillStyle = "rgba(255,255,255,1)";	// 白色にする
				context.fillRect(0,0,800,600);	// キャンバスを消去
				}	
				document.getElementById("up").onclick = function(){
				//context.save();	// 現在の状態を保存

				a = eval(document.getElementById("stOpac").value);
				context.lineWidth = eval(document.getElementById("stWidth").value);
				context.save();	// 現在の状態を保存
				}
				//描画イベント
				document.getElementById("plotArea").onmousedown = function(){
					mousehand = true;
				}
				document.getElementById("plotArea").onmouseup = function(){
					mousehand = false
				}
			}

			//function up{
			//context.fillStyle = "rgba(255,255,255,1)";
			//	context.fillRect(zureX,zureY,800,600);
			//	alert("aaa");
			//}
