<! Doctype html public "-// w3c // dtd xhtml 1.0 transisi // 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> tanpa judul 1 </title> <style type = "text/cs: cs: cs: cs: cs: {{title> {{title> {{{title> title; } </style> <type skrip = "text/javascript">/** menggambar poin*/function makeDot (x, y) {pointDiv = "<div style = 'tinggi: 1px; posisi: absolute; kiri:" + x + "px; atas:" + y + "px; width: 1px; latar belakang:#f00; overflow: overflow: hiding" px; width: 1px; latar belakang:#f00; overflow; Return pointDiv;} /** Gambar garis lurus berdasarkan koordinat dari dua poin. */ garis fungsi (x1, y1, x2, y2) {var slope; // slope var arah; // koordinat gerakan var tx = x2 - x1; var ty = y2 - y1; if (tx == 0 && ty == 0) return; var points = ""; var axis; // koordinat pada sumbu if (math.abs (tx)> = math.abs (ty)) {// pindahkan arah = tx> 0? 1: -1; tx = math.abs (tx); kemiringan = ty / tx; sumbu = x1; untuk (i = 0; i <tx; i ++) {points += makedot (axis, y1 +i * slope); sumbu += arah; }} else {// Pindahkan arah pada arah sumbu y = ty> 0? 1: -1; ty = math.abs (ty); slope = tx / ty; sumbu = y1; untuk (i = 0; i <ty; i ++) {points += makedot (x1 +i * slope, axis); sumbu += arah; }} var container = document.getElementById ("container"); container.innerhtml += poin; } var OldPoint = null; // Dapatkan fungsi posisi mouse 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); return {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 = "container" ontClick = "RecordPoint (event);"> </div> <script type = "text/javascript"> // line (19,19,22,300); </script> </body> </html>