<! doctype html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type"content = "text/html; charset = utf-8"/> <title> 제목없는 1 </title> <text/css ">. . return pointdiv;} /** 두 지점의 좌표에 따라 직선을 그립니다. */ 기능 라인 (x1, y1, x2, y2) {var slope; // 슬로프 var 방향; // 좌표 모션 var tx = x2 -x1; var ty = y2 -y1; if (tx == 0 && ty == 0) 반환; var points = ""; var Axis; // 축의 조정 if (math.abs (tx)> = math.abs (ty)) {// direction = tx> 0? 1 : -1; tx = math.abs (tx); 경사 = ty / tx; 축 = x1; for (i = 0; i <tx; i ++) {points += makedot (Axis, y1 +i * slope); 축 += 방향; }} else {// y 축 방향의 방향 = ty> 0? 1 : -1; ty = math.abs (ty); 경사 = TX / TY; 축 = Y1; for (i = 0; i <ty; i ++) {points += makedot (x1 +i * 경사, 축); 축 += 방향; }} var 컨테이너 = document.getElementById ( "컨테이너"); container.innerhtml += 포인트; } var oldpoint = null; // 마우스 위치를 가져옵니다. 함수 mouseposition (ev) {ev = ev || Window.event; if (ev.pagex || ev.pagey) {return {x : ev.pagex, y : ev.pagey}; } var doc = document.documentElement, body = document.body; var pagex = event.clientx + (doc && doc.scrollleft || body && body.scrollleft || 0) - (doc && doc.clientleft || body && body.clientleft || 0); var pagey = event.clienty + (doc && doc.scrolltop || body && body.scrolltop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); 반환 {x : pagex, y : pagey};} function recordpoint (ev) {var point = mouseposition (ev); if (OldPoint! = null) {line (OldPoint.x, OldPoint.y, Point.x, Point.y); } OldPoint = point;} </script> </head> <body> <div id = "컨테이너"onclick = "recordpoint (event);"> </div> <script type = "text/javaScript"> // line (19,19,22,300); </script> </body> </html>