neyric/wireit

View on GitHub
build/arrow-wire/arrow-wire-min.js

Summary

Maintainability
A
0 mins
Test Coverage
YUI.add("arrow-wire",function(e,t){"use strict";e.ArrowWire=function(t){e.ArrowWire.superclass.constructor.apply(this,arguments)},e.ArrowWire.NAME="arrowwire",e.extend(e.ArrowWire,e.WireBase,{_drawArrow:function(e,t){var n=7,r=Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)),i=20,s=r===0?0:1-i/r,o=[Math.abs(e[0]+s*(t[0]-e[0])),Math.abs(e[1]+s*(t[1]-e[1]))],u=e[0]-t[0],a=e[1]-t[1],f=e[0]*t[1]-e[1]*t[0],l,c,h,p,d,v,m,g,y,b,w,E,S;u!==0?(l=a/u,c=f/u):l=0,l===0?h=0:h=-1/l,p=o[1]-h*o[0],d=1+Math.pow(h,2),v=2*h*p-2*o[0]-2*o[1]*h,m=-2*o[1]*p+Math.pow(o[0],2)+Math.pow(o[1],2)-Math.pow(n,2)+Math.pow(p,2),g=Math.pow(v,2)-4*d*m;if(g<0)return;y=(-v+Math.sqrt(g))/(2*d),b=(-v-Math.sqrt(g))/(2*d),w=h*y+p,E=h*b+p,e[1]===t[1]&&(S=e[0]>t[0]?1:-1,y=t[0]+S*i,b=y,w-=n,E+=n),this.moveTo(t[0]+6,t[1]+6),this.lineTo(y+6,w+6),this.moveTo(t[0]+6,t[1]+6),this.lineTo(b+6,E+6)},_draw:function(){this.clear();var e=this.get("src").getXY(),t=this.get("tgt").getXY();this.moveTo(e[0]+6,e[1]+6),this.lineTo(t[0]+6,t[1]+6),this._drawArrow(e,t),this.end()}}),e.ArrowWire.ATTRS=e.merge(e.WireBase.ATTRS,{})},"@VERSION@",{requires:["wire-base"]});