Amostra:
Menos bobagem, basta fazer o upload do código:
Arrow.js
/*** Implemente a função de desenhar setas entre dois pontos* @author [email protected]* @version 1.0* @date 2013.05.23*/; (function (window, document) {if (window.mapleQuque == não define) /** * Receba objeto de tela e desenhe setas aqui (o ponto de partida e o ponto final da seta foi definido) * @param contexto * /pintura: function (context) {pinting (this, context);}, /** * Defina a seta STOW e o ponto final * Point * @param SP Point * @param EP Point * @Param ST Intensidade * /set: SPUN (SPEL, SP, SP, SP), ST); Defina a aparência de seta * @param args */setpara: function (args) {this.size = args.arrow_size; // tamanho da seta this.sharp = args.arrow_sharp; // seta sharp e start}}; Paint = função (a, contexto) {var = a.sp; context.moveto (sp.x, sp.y); context.lineto (ep.x, ep.y); // desenhe a cabeça de seta var h = _calch (a, sp, ep, contexto); 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 (); }; // calcule a coordenada da cabeça var _calch = function (a, sp, ep, contexto) {var theta = math.atan ((ep.x-sp.x)/(ep.y-sp.y)); var cep = _scrollxoy (ep, -teta); var csp = _scrollxoy (sp, -teta); 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, teta); retornar {h1: h1, h2: h2}; }; // coordenadas de rotação var _scrollxoy = function (p, teta) {return {x: px*math.cos (teta)+py*math.sin (teta), y: py*math.cos (theta) -px*math.sin (theta)}; }; var Arrow = new Function (); Arrow.prototype = Proc; window.mapleque.arrow = seta;}) (janela, documento);
Arrow.html
<! Doctype html> <html> <head> <meta charset = "utf-8"> <title> amostra da seta </ititle> <script type = "text/javascript" src = "./ Arrow.js"> </script> </head> <body> <seva ". Html5 </canvas> <script type = "text/javascript"> var content = document.getElementById ("Arrowline"). window.mapleque.arrow (); a2.set ({x: 100, y: 100}, {x: 200, y: 250}); a2.paint (cont); var a3 = new window.mapleque.arrow (); a3.set ({x: 100, y: 300}, {x: 150, y: y: y: y: y: y: y: y: y: y: y: y: y: y: a3.111s; 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> </ht: