Mencicipi:
Kurang omong kosong, cukup unggah kode:
panah.js
/*** Menerapkan fungsi panah menggambar antara dua titik* @author [email protected]* @Version 1.0* @Date 2013.05.23*/; (function, window, dokumen) {if (window.mapleque == tidak terdefinisi) window.mapleque = {}; if (window.mapleque! /** * Menerima objek kanvas dan menggambar panah di sini (titik awal dan akhir panah telah ditetapkan) * @param Context * /Paint: function (konteks) {cat (ini, konteks);}, /** * atur panah mulai dan titik akhir, /@param sp start point * @param eP titik akhir * @param st Intensity * /set: function @param sp, st) {Staram) (function), St.) @p, St.) @p, St.) @p, /st. Atur penampilan panah * @param args */setpara: function (args) {this.size = args.arrow_size; // ukuran panah this.sharp = args.arrow_sharp; // panah tajam dan blunt}; function = A, konteks) {var sp = a.sp; context.moveto (sp.x, sp.y); Context.lineto (Ep.x, Ep.Y); // Gambar kepala panah var h = _calch (a, sp, ep, konteks); Context.moveto (Ep.x, Ep.Y); Context.lineto (H.H1.X, H.H1.Y); Context.moveto (Ep.x, Ep.Y); Context.lineto (Ep.x, Ep.Y); Context.lineto (H.H2.X, H.H2.Y); Context.stroke (); }; // Hitung koordinat kepala var _calch = fungsi (a, sp, ep, konteks) {var theta = math.atan ((eP.x-sp.x)/(ep.y-sp.y)); var cep = _scrollxoy (ep, -theta); var csp = _scrollxoy (sp, -theta); var ch1 = {x: 0, y: 0}; var ch2 = {x: 0, y: 0}; var l = cep.y-csp.y; ch1.x = cep.x+l*(a.sharp || 0,025); ch1.y = cep.yl*(a.size || 0,05); ch2.x = cep.xl*(a.sharp || 0.025); ch2.y = cep.yl*(a.size || 0,05); var h1 = _scrollxoy (ch1, theta); var h2 = _scrollxoy (ch2, theta); return {h1: h1, h2: h2}; }; // rotasi koordinat var _scrollxoy = function (p, theta) {return {x: px*math.cos (theta)+py*math.sin (theta), y: py*math.cos (theta) -px*math.sin (theta)}; }; var panah = fungsi baru (); panah.prototype = proc; window.mapleque.arrow = panah;}) (jendela, dokumen);
panah.html
<! Doctype html> <html> <head> <meta charset = "utf-8"> <itement> sampel panah </itement> <script type = "text/javascript" src = "./ panah.js"> </script> </head> <body> <canvas a canvas lebarnya = 800 id = 600 id = " Html5 </canvas> <script type = "text/javaScript"> var content = document.geteLementById ("arrowline"). GetContext ('2d'); var a1 = window.mapleque.arrow (); a1 ({200 {350, y: 300 {x: {x: {200 {350, window.mapleque.arrow (); a2.set ({x: 100, y: 100}, {x: 200, y: 250}); a2.paint (cont); var a3 = window.mapleque.arrow (); a3.set ({x: 100, y: 300}, {x: 150, y: y: y: {x: y: 300}, {x: 150, y: y: y: {x: y: 300}, {x: 150, y: y: y: {x: y: 300}, {x: 150, y: y: y: {x: y: 300}, {x: 150, y: y: y: {x: y: 300}, {x: 150, y: y: y: {x: y: 300} window.mapleque.arrow (); a4.set ({x: 350, y: 150}, {x: 150, y: 250}); a4.setpara ({arrow_size: 0.5, arrow_sharp: 0.5}) a4.paint (cont); </script> </body> </html>