1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 07:40:07 +02:00
copilot/spikes/architecture/sigmajs/vendor/plugins/sigma.renderers.edgeDots.min.js
2016-11-07 13:57:21 +00:00

1 line
3.1 KiB
JavaScript

!function(){"use strict";function a(a,b,c,d,f,g,h,i,j){a.beginPath(),a.fillStyle=j;var k=e(b,c,d.x,d.y,f,g,h);a.arc(k.x,k.y,3*i,0,2*Math.PI,!1),a.fill()}function b(a,b,c,d){var e=1-a;return e*e*b+2*e*a*c+a*a*d}function c(a,c,d,e,f,g,h){return{x:b(h,a,d,f),y:b(h,c,e,g)}}function d(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))}function e(a,b,e,f,g,h,i){for(var j=0,k=1e3,l=.001,m=0;m<1;m+=l){var n=c(a,b,e,f,g,h,m),o=d(a,b,n.x,n.y);Math.abs(o-i)<k&&(k=Math.abs(o-i),j=m)}return c(a,b,e,f,g,h,j)}sigma.utils.pkg("sigma.canvas.edges"),sigma.canvas.edges.dotCurve=function(b,c,d,e,f){var g=b.color,h=f("prefix")||"",i=b[h+"size"]||1,j=f("edgeColor"),k=f("defaultNodeColor"),l=f("defaultEdgeColor"),m={},n=c[h+"size"],o=c[h+"x"],p=c[h+"y"],q=d[h+"x"],r=d[h+"y"];if(m=c.id===d.id?sigma.utils.getSelfLoopControlPoints(o,p,n):sigma.utils.getQuadraticControlPoint(o,p,q,r),!g)switch(j){case"source":g=c.color||k;break;case"target":g=d.color||k;break;default:g=l}if(e.strokeStyle=g,e.lineWidth=i,e.beginPath(),e.moveTo(o,p),c.id===d.id?e.bezierCurveTo(m.x1,m.y1,m.x2,m.y2,q,r):e.quadraticCurveTo(m.x,m.y,q,r),e.stroke(),void 0!=b.sourceDotColor||void 0!=b.targetDotColor){var s=b.dotOffset||3,t=b.dotSize||1;t*=i,s*=n,void 0!=b.sourceDotColor&&a(e,o,p,m,q,r,s,t,b.sourceDotColor),void 0!=b.targetDotColor&&a(e,q,r,m,o,p,s,t,b.targetDotColor)}}}(),function(){"use strict";function a(a,b,c,d,f,g,h,i,j){a.beginPath(),a.fillStyle=j;var k=e(b,c,d.x,d.y,f,g,h);a.arc(k.x,k.y,3*i,0,2*Math.PI,!1),a.fill()}function b(a,b,c,d){var e=1-a;return e*e*b+2*e*a*c+a*a*d}function c(a,c,d,e,f,g,h){return{x:b(h,a,d,f),y:b(h,c,e,g)}}function d(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))}function e(a,b,e,f,g,h,i){for(var j=0,k=1e3,l=.001,m=0;m<1;m+=l){var n=c(a,b,e,f,g,h,m),o=d(a,b,n.x,n.y);Math.abs(o-i)<k&&(k=Math.abs(o-i),j=m)}return c(a,b,e,f,g,h,j)}sigma.utils.pkg("sigma.canvas.edges"),sigma.canvas.edges.dotCurvedArrow=function(b,c,d,e,f){var g,h,i,j,k,l=b.color,m=f("prefix")||"",n=f("edgeColor"),o=f("defaultNodeColor"),p=f("defaultEdgeColor"),q={},r=b[m+"size"]||1,s=b.count||0,t=d[m+"size"],u=c[m+"x"],v=c[m+"y"],w=d[m+"x"],x=d[m+"y"],y=Math.max(2.5*r,f("minArrowSize"));if(q=c.id===d.id?sigma.utils.getSelfLoopControlPoints(u,v,t,s):sigma.utils.getQuadraticControlPoint(u,v,w,x,s),c.id===d.id?(g=Math.sqrt(Math.pow(w-q.x1,2)+Math.pow(x-q.y1,2)),h=q.x1+(w-q.x1)*(g-y-t)/g,i=q.y1+(x-q.y1)*(g-y-t)/g,j=(w-q.x1)*y/g,k=(x-q.y1)*y/g):(g=Math.sqrt(Math.pow(w-q.x,2)+Math.pow(x-q.y,2)),h=q.x+(w-q.x)*(g-y-t)/g,i=q.y+(x-q.y)*(g-y-t)/g,j=(w-q.x)*y/g,k=(x-q.y)*y/g),!l)switch(n){case"source":l=c.color||o;break;case"target":l=d.color||o;break;default:l=p}if(e.strokeStyle=l,e.lineWidth=r,e.beginPath(),e.moveTo(u,v),c.id===d.id?e.bezierCurveTo(q.x2,q.y2,q.x1,q.y1,h,i):e.quadraticCurveTo(q.x,q.y,h,i),e.stroke(),e.fillStyle=l,e.beginPath(),e.moveTo(h+j,i+k),e.lineTo(h+.6*k,i-.6*j),e.lineTo(h-.6*k,i+.6*j),e.lineTo(h+j,i+k),e.closePath(),e.fill(),void 0!=b.sourceDotColor||void 0!=b.targetDotColor){var z=b.dotOffset||3,A=b.dotSize||1;A*=r,z*=t,void 0!=b.sourceDotColor&&a(e,u,v,q,w,x,z,A,b.sourceDotColor),void 0!=b.targetDotColor&&a(e,w,x,q,u,v,z,A,b.targetDotColor)}}}();