340 lines
458 KiB
JavaScript
340 lines
458 KiB
JavaScript
|
|
import{a as v}from"./chunk-GTKDMUJJ.mjs";function Ps(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}v(Ps,"_arrayLikeToArray");function rc(r){if(Array.isArray(r))return r}v(rc,"_arrayWithHoles");function tc(r){if(Array.isArray(r))return Ps(r)}v(tc,"_arrayWithoutHoles");function gt(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}v(gt,"_classCallCheck");function ac(r,e){for(var t=0;t<e.length;t++){var a=e[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,ev(a.key),a)}}v(ac,"_defineProperties");function pt(r,e,t){return e&&ac(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}v(pt,"_createClass");function Dr(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=Ys(r))||e){t&&(r=t);var a=0,n=v(function(){},"F");return{s:n,n:v(function(){return a>=r.length?{done:!0}:{done:!1,value:r[a++]}},"n"),e:v(function(l){throw l},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,o=!1;return{s:v(function(){t=t.call(r)},"s"),n:v(function(){var l=t.next();return s=l.done,l},"n"),e:v(function(l){o=!0,i=l},"e"),f:v(function(){try{s||t.return==null||t.return()}finally{if(o)throw i}},"f")}}v(Dr,"_createForOfIteratorHelper");function jl(r,e,t){return(e=ev(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}v(jl,"_defineProperty$1");function nc(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}v(nc,"_iterableToArray");function ic(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var a,n,i,s,o=[],l=!0,u=!1;try{if(i=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(a=i.call(t)).done)&&(o.push(a.value),o.length!==e);l=!0);}catch(f){u=!0,n=f}finally{try{if(!l&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw n}}return o}}v(ic,"_iterableToArrayLimit");function sc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}v(sc,"_nonIterableRest");function oc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}v(oc,"_nonIterableSpread");function je(r,e){return rc(r)||ic(r,e)||Ys(r,e)||sc()}v(je,"_slicedToArray");function bn(r){return tc(r)||nc(r)||Ys(r)||oc()}v(bn,"_toConsumableArray");function uc(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var a=t.call(r,e);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}v(uc,"_toPrimitive");function ev(r){var e=uc(r,"string");return typeof e=="symbol"?e:e+""}v(ev,"_toPropertyKey");function nr(r){"@babel/helpers - typeof";return nr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nr(r)}v(nr,"_typeof");function Ys(r,e){if(r){if(typeof r=="string")return Ps(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ps(r,e):void 0}}v(Ys,"_unsupportedIterableToArray");var tr=typeof window>"u"?null:window,So=tr?tr.navigator:null;tr&&tr.document;var lc=nr(""),rv=nr({}),vc=nr(function(){}),fc=typeof HTMLElement>"u"?"undefined":nr(HTMLElement),Ia=v(function(e){return e&&e.instanceString&&Ke(e.instanceString)?e.instanceString():null},"instanceStr"),pe=v(function(e){return e!=null&&nr(e)==lc},"string"),Ke=v(function(e){return e!=null&&nr(e)===vc},"fn"),Ge=v(function(e){return!Br(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},"array"),Ie=v(function(e){return e!=null&&nr(e)===rv&&!Ge(e)&&e.constructor===Object},"plainObject"),cc=v(function(e){return e!=null&&nr(e)===rv},"object"),ne=v(function(e){return e!=null&&nr(e)===nr(1)&&!isNaN(e)},"number"),dc=v(function(e){return ne(e)&&Math.floor(e)===e},"integer"),wn=v(function(e){if(fc!=="undefined")return e!=null&&e instanceof HTMLElement},"htmlElement"),Br=v(function(e){return Oa(e)||tv(e)},"elementOrCollection"),Oa=v(function(e){return Ia(e)==="collection"&&e._private.single},"element"),tv=v(function(e){return Ia(e)==="collection"&&!e._private.single},"collection"),Zs=v(function(e){return Ia(e)==="core"},"core"),av=v(function(e){return Ia(e)==="stylesheet"},"stylesheet"),hc=v(function(e){return Ia(e)==="event"},"event"),lt=v(function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},"emptyString"),gc=v(function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},"domElement"),pc=v(function(e){return Ie(e)&&ne(e.x1)&&ne(e.x2)&&ne(e.y1)&&ne(e.y2)},"boundingBox"),yc=v(function(e){return cc(e)&&Ke(e.then)},"promise"),mc=v(function(){return So&&So.userAgent.match(/msie|trident|edge/i)},"ms"),Jt=v(function(e,t){t||(t=v(function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],s=0;s<arguments.length;s++)i.push(arguments[s]);return i.join("$")},"keyFn"));var a=v(function(){var i=this,s=arguments,o,l=t.apply(i,s),u=a.cache;return(o=u[l])||(o=u[l]=e.apply(i,s)),o},"memoizedFn");return a.cache={},a},"memoize"),Qs=Jt(function(r){return r.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),Ln=Jt(function(r){return r.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),nv=Jt(function(r,e){return r+e[0].toUpperCase()+e.substring(1)},function(r,e){return r+"$"+e}),ko=v(function(e){return lt(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},"capitalize"),nt=v(function(e,t){return e.slice(-1*t.length)===t},"endsWith"),ar="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",bc="rgb[a]?\\(("+ar+"[%]?)\\s*,\\s*("+ar+"[%]?)\\s*,\\s*("+ar+"[%]?)(?:\\s*,\\s*("+ar+"))?\\)",wc="rgb[a]?\\((?:"+ar+"[%]?)\\s*,\\s*(?:"+ar+"[%]?)\\s*,\\s*(?:"+ar+"[%]?)(?:\\s*,\\s*(?:"+ar+"))?\\)",xc="hsl[a]?\\(("+ar+")\\s*,\\s*("+ar+"[%])\\s*,\\s*("+ar+"[%])(?:\\s*,\\s*("+ar+"))?\\)",Ec="hsl[a]?\\((?:"+ar+")\\s*,\\s*(?:"+ar+"[%])\\s*,\\s*(?:"+ar+"[%])(?:\\s*,\\s*(?:"+ar+"))?\\)",Cc="\\#[0-9a-fA-F]{3}",Tc="\\#[0-9a-fA-F]{6}",iv=v
|
||
|
|
`),c=r.pstyle("text-max-width").pfValue,d=r.pstyle("text-overflow-wrap").value,g=d==="anywhere",h=[],m=/[\s\u200b]+|$/g,p=0;p<f.length;p++){var y=f[p],b=this.calculateLabelDimensions(r,y),w=b.width;if(g){var x=y.split("").join(u);y=x}if(w>c){var C=y.matchAll(m),T="",E=0,S=Dr(C),D;try{for(S.s();!(D=S.n()).done;){var B=D.value,P=B[0],A=y.substring(E,B.index);E=B.index+P.length;var R=T.length===0?A:T+A+P,M=this.calculateLabelDimensions(r,R),I=M.width;I<=c?T+=A+P:(T&&h.push(T),T=A+P)}}catch(V){S.e(V)}finally{S.f()}T.match(/^[\s\u200b]+$/)||h.push(T)}else h.push(y)}s("labelWrapCachedLines",h),n=s("labelWrapCachedText",h.join(`
|
||
|
|
`)),s("labelWrapKey",l)}else if(o==="ellipsis"){var O=r.pstyle("text-max-width").pfValue,L="",N="\u2026",q=!1;if(this.calculateLabelDimensions(r,n).width<O)return n;for(var H=0;H<n.length;H++){var z=this.calculateLabelDimensions(r,L+n[H]+N).width;if(z>O)break;L+=n[H],H===n.length-1&&(q=!0)}return q||(L+=N),L}return n};Hr.getLabelJustification=function(r){var e=r.pstyle("text-justification").strValue,t=r.pstyle("text-halign").strValue;if(e==="auto")if(r.isNode())switch(t){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e};Hr.calculateLabelDimensions=function(r,e){var t=this,a=t.cy.window(),n=a.document,i=0,s=r.pstyle("font-style").strValue,o=r.pstyle("font-size").pfValue,l=r.pstyle("font-family").strValue,u=r.pstyle("font-weight").strValue,f=this.labelCalcCanvas,c=this.labelCalcCanvasContext;if(!f){f=this.labelCalcCanvas=n.createElement("canvas"),c=this.labelCalcCanvasContext=f.getContext("2d");var d=f.style;d.position="absolute",d.left="-9999px",d.top="-9999px",d.zIndex="-1",d.visibility="hidden",d.pointerEvents="none"}c.font="".concat(s," ").concat(u," ").concat(o,"px ").concat(l);for(var g=0,h=0,m=e.split(`
|
||
|
|
`),p=0;p<m.length;p++){var y=m[p],b=c.measureText(y),w=Math.ceil(b.width),x=o;g=Math.max(w,g),h+=x}return g+=i,h+=i,{width:g,height:h}};Hr.calculateLabelAngle=function(r,e){var t=r._private,a=t.rscratch,n=r.isEdge(),i=e?e+"-":"",s=r.pstyle(i+"text-rotation"),o=s.strValue;return o==="none"?0:n&&o==="autorotate"?a.labelAutoAngle:o==="autorotate"?0:s.pfValue};Hr.calculateLabelAngles=function(r){var e=this,t=r.isEdge(),a=r._private,n=a.rscratch;n.labelAngle=e.calculateLabelAngle(r),t&&(n.sourceLabelAngle=e.calculateLabelAngle(r,"source"),n.targetLabelAngle=e.calculateLabelAngle(r,"target"))};var xf={},Il=28,Ol=!1;xf.getNodeShape=function(r){var e=this,t=r.pstyle("shape").value;if(t==="cutrectangle"&&(r.width()<Il||r.height()<Il))return Ol||(qe("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Ol=!0),"rectangle";if(r.isParent())return t==="rectangle"||t==="roundrectangle"||t==="round-rectangle"||t==="cutrectangle"||t==="cut-rectangle"||t==="barrel"?t:"rectangle";if(t==="polygon"){var a=r.pstyle("shape-polygon-points").value;return e.nodeShapes.makePolygon(a).name}return t};var Yn={};Yn.registerCalculationListeners=function(){var r=this.cy,e=r.collection(),t=this,a=v(function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(s),o)for(var l=0;l<s.length;l++){var u=s[l],f=u._private,c=f.rstyle;c.clean=!1,c.cleanConnected=!1}},"enqueue");t.binder(r).on("bounds.* dirty.*",v(function(s){var o=s.target;a(o)},"onDirtyBounds")).on("style.* background.*",v(function(s){var o=s.target;a(o,!1)},"onDirtyStyle"));var n=v(function(s){if(s){var o=t.onUpdateEleCalcsFns;e.cleanStyle();for(var l=0;l<e.length;l++){var u=e[l],f=u._private.rstyle;u.isNode()&&!f.cleanConnected&&(a(u.connectedEdges()),f.cleanConnected=!0)}if(o)for(var c=0;c<o.length;c++){var d=o[c];d(s,e)}t.recalculateRenderedStyle(e),e=r.collection()}},"updateEleCalcs");t.flushRenderedStyleQueue=function(){n(!0)},t.beforeRender(n,t.beforeRenderPriorities.eleCalcs)};Yn.onUpdateEleCalcs=function(r){var e=this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[];e.push(r)};Yn.recalculateRenderedStyle=function(r,e){var t=v(function(x){return x._private.rstyle.cleanConnected},"isCleanConnected");if(r.length!==0){var a=[],n=[];if(!this.destroyed){e===void 0&&(e=!0);for(var i=0;i<r.length;i++){var s=r[i],o=s._private,l=o.rstyle;s.isEdge()&&(!t(s.source())||!t(s.target()))&&(l.clean=!1),s.isEdge()&&s.isBundledBezier()&&s.parallelEdges().some(function(w){return!w._private.rstyle.clean&&w.isBundledBezier()})&&(l.clean=!1),!(e&&l.clean||s.removed())&&s.pstyle("display").value!=="none"&&(o.group==="nodes"?n.push(s):a.push(s),l.clean=!0)}for(var u=0;u<n.length;u++){var f=n[u],c=f._private,d=c.rstyle,g=f.position();this.recalculateNodeLabelProjection(f),d.nodeX=g.x,d.nodeY=g.y,d.nodeW=f.pstyle("width").pfValue,d.nodeH=f.pstyle("height").pfValue}this.recalculateEdgeProjections(a);for(var h=0;h<a.length;h++){var m=a[h],p=m._private,y=p.rstyle,b=p.rscratch;y.srcX=b.arrowStartX,y.srcY=b.arrowStartY,y.tgtX=b.arrowEndX,y.tgtY=b.arrowEndY,y.midX=b.midX,y.midY=b.midY,y.labelAngle=b.labelAngle,y.sourceLabelAngle=b.sourceLabelAngle,y.targetLabelAngle=b.targetLabelAngle}}}};var Zn={};Zn.updateCachedGrabbedEles=function(){var r=this.cachedZSortedEles;if(r){r.drag=[],r.nondrag=[];for(var e=[],t=0;t<r.length;t++){var a=r[t],n=a._private.rscratch;a.grabbed()&&!a.isParent()?e.push(a):n.inDragLayer?r.drag.push(a):r.nondrag.push(a)}for(var t=0;t<e.length;t++){var a=e[t];r.drag.push(a)}}};Zn.invalidateCachedZSortedEles=function(){this.cachedZSortedEles=null};Zn.getCachedZSortedEles=function(r){if(r||!this.cachedZSortedEles){var e=this.cy.mutableElements().toArray();e.sort(rf),e.interactive=e.filter(function(t){return t.interactive()}),this.cachedZSortedEles=e,this.updateCachedGrabbedEles()}else e=this.cachedZSortedEles;return e};var Ef={};[It,Pn,mr,Ha,mo,Hr,xf,Yn,Zn].forEach(function(r){we(Ef,r)});var Cf={};Cf.getCachedImage=function(r,e,t){var a=this,n=a.imageCache=a.imageCache||{},i=n[r];if(i)return i.image.complete||i.image.addEventListener("l
|
||
|
|
float circleSD(vec2 p, float r) {
|
||
|
|
return distance(vec2(0), p) - r; // signed distance
|
||
|
|
}
|
||
|
|
`,lm=`
|
||
|
|
float rectangleSD(vec2 p, vec2 b) {
|
||
|
|
vec2 d = abs(p)-b;
|
||
|
|
return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);
|
||
|
|
}
|
||
|
|
`,vm=`
|
||
|
|
float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {
|
||
|
|
cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;
|
||
|
|
cr.x = (p.y > 0.0) ? cr.x : cr.y;
|
||
|
|
vec2 q = abs(p) - b + cr.x;
|
||
|
|
return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;
|
||
|
|
}
|
||
|
|
`,fm=`
|
||
|
|
float ellipseSD(vec2 p, vec2 ab) {
|
||
|
|
p = abs( p ); // symmetry
|
||
|
|
|
||
|
|
// find root with Newton solver
|
||
|
|
vec2 q = ab*(p-ab);
|
||
|
|
float w = (q.x<q.y)? 1.570796327 : 0.0;
|
||
|
|
for( int i=0; i<5; i++ ) {
|
||
|
|
vec2 cs = vec2(cos(w),sin(w));
|
||
|
|
vec2 u = ab*vec2( cs.x,cs.y);
|
||
|
|
vec2 v = ab*vec2(-cs.y,cs.x);
|
||
|
|
w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));
|
||
|
|
}
|
||
|
|
|
||
|
|
// compute final point and distance
|
||
|
|
float d = length(p-ab*vec2(cos(w),sin(w)));
|
||
|
|
|
||
|
|
// return signed distance
|
||
|
|
return (dot(p/ab,p/ab)>1.0) ? d : -d;
|
||
|
|
}
|
||
|
|
`,Ca={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},Rn={IGNORE:1,USE_BB:2},Ts=0,Xl=1,Yl=2,Ss=3,Ht=4,on=5,pa=6,ya=7,cm=(function(){function r(e,t,a){gt(this,r),this.r=e,this.gl=t,this.maxInstances=a.webglBatchSize,this.atlasSize=a.webglTexSize,this.bgColor=a.bgColor,this.debug=a.webglDebug,this.batchDebugInfo=[],a.enableWrapping=!0,a.createTextureCanvas=Wy,this.atlasManager=new sm(e,a),this.batchManager=new om(a),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(Ca.SCREEN),this.pickingProgram=this._createShaderProgram(Ca.PICKING),this.vao=this._createVAO()}return v(r,"ElementDrawingWebGL"),pt(r,[{key:"addAtlasCollection",value:v(function(t,a){this.atlasManager.addAtlasCollection(t,a)},"addAtlasCollection")},{key:"addTextureAtlasRenderType",value:v(function(t,a){this.atlasManager.addRenderType(t,a)},"addTextureAtlasRenderType")},{key:"addSimpleShapeRenderType",value:v(function(t,a){this.simpleShapeOptions.set(t,a)},"addSimpleShapeRenderType")},{key:"invalidate",value:v(function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.type,i=this.atlasManager;return n?i.invalidate(t,{filterType:v(function(o){return o===n},"filterType"),forceRedraw:!0}):i.invalidate(t)},"invalidate")},{key:"gc",value:v(function(){this.atlasManager.gc()},"gc")},{key:"_createShaderProgram",value:v(function(t){var a=this.gl,n=`#version 300 es
|
||
|
|
precision highp float;
|
||
|
|
|
||
|
|
uniform mat3 uPanZoomMatrix;
|
||
|
|
uniform int uAtlasSize;
|
||
|
|
|
||
|
|
// instanced
|
||
|
|
in vec2 aPosition; // a vertex from the unit square
|
||
|
|
|
||
|
|
in mat3 aTransform; // used to transform verticies, eg into a bounding box
|
||
|
|
in int aVertType; // the type of thing we are rendering
|
||
|
|
|
||
|
|
// the z-index that is output when using picking mode
|
||
|
|
in vec4 aIndex;
|
||
|
|
|
||
|
|
// For textures
|
||
|
|
in int aAtlasId; // which shader unit/atlas to use
|
||
|
|
in vec4 aTex; // x/y/w/h of texture in atlas
|
||
|
|
|
||
|
|
// for edges
|
||
|
|
in vec4 aPointAPointB;
|
||
|
|
in vec4 aPointCPointD;
|
||
|
|
in vec2 aLineWidth; // also used for node border width
|
||
|
|
|
||
|
|
// simple shapes
|
||
|
|
in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]
|
||
|
|
in vec4 aColor; // also used for edges
|
||
|
|
in vec4 aBorderColor; // aLineWidth is used for border width
|
||
|
|
|
||
|
|
// output values passed to the fragment shader
|
||
|
|
out vec2 vTexCoord;
|
||
|
|
out vec4 vColor;
|
||
|
|
out vec2 vPosition;
|
||
|
|
// flat values are not interpolated
|
||
|
|
flat out int vAtlasId;
|
||
|
|
flat out int vVertType;
|
||
|
|
flat out vec2 vTopRight;
|
||
|
|
flat out vec2 vBotLeft;
|
||
|
|
flat out vec4 vCornerRadius;
|
||
|
|
flat out vec4 vBorderColor;
|
||
|
|
flat out vec2 vBorderWidth;
|
||
|
|
flat out vec4 vIndex;
|
||
|
|
|
||
|
|
void main(void) {
|
||
|
|
int vid = gl_VertexID;
|
||
|
|
vec2 position = aPosition; // TODO make this a vec3, simplifies some code below
|
||
|
|
|
||
|
|
if(aVertType == `.concat(Ts,`) {
|
||
|
|
float texX = aTex.x; // texture coordinates
|
||
|
|
float texY = aTex.y;
|
||
|
|
float texW = aTex.z;
|
||
|
|
float texH = aTex.w;
|
||
|
|
|
||
|
|
if(vid == 1 || vid == 2 || vid == 4) {
|
||
|
|
texX += texW;
|
||
|
|
}
|
||
|
|
if(vid == 2 || vid == 4 || vid == 5) {
|
||
|
|
texY += texH;
|
||
|
|
}
|
||
|
|
|
||
|
|
float d = float(uAtlasSize);
|
||
|
|
vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1
|
||
|
|
|
||
|
|
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
|
||
|
|
}
|
||
|
|
else if(aVertType == `).concat(Ht," || aVertType == ").concat(ya,`
|
||
|
|
|| aVertType == `).concat(on," || aVertType == ").concat(pa,`) { // simple shapes
|
||
|
|
|
||
|
|
// the bounding box is needed by the fragment shader
|
||
|
|
vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat
|
||
|
|
vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat
|
||
|
|
vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated
|
||
|
|
|
||
|
|
// calculations are done in the fragment shader, just pass these along
|
||
|
|
vColor = aColor;
|
||
|
|
vCornerRadius = aCornerRadius;
|
||
|
|
vBorderColor = aBorderColor;
|
||
|
|
vBorderWidth = aLineWidth;
|
||
|
|
|
||
|
|
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
|
||
|
|
}
|
||
|
|
else if(aVertType == `).concat(Xl,`) {
|
||
|
|
vec2 source = aPointAPointB.xy;
|
||
|
|
vec2 target = aPointAPointB.zw;
|
||
|
|
|
||
|
|
// adjust the geometry so that the line is centered on the edge
|
||
|
|
position.y = position.y - 0.5;
|
||
|
|
|
||
|
|
// stretch the unit square into a long skinny rectangle
|
||
|
|
vec2 xBasis = target - source;
|
||
|
|
vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
|
||
|
|
vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;
|
||
|
|
|
||
|
|
gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
|
||
|
|
vColor = aColor;
|
||
|
|
}
|
||
|
|
else if(aVertType == `).concat(Yl,`) {
|
||
|
|
vec2 pointA = aPointAPointB.xy;
|
||
|
|
vec2 pointB = aPointAPointB.zw;
|
||
|
|
vec2 pointC = aPointCPointD.xy;
|
||
|
|
vec2 pointD = aPointCPointD.zw;
|
||
|
|
|
||
|
|
// adjust the geometry so that the line is centered on the edge
|
||
|
|
position.y = position.y - 0.5;
|
||
|
|
|
||
|
|
vec2 p0, p1, p2, pos;
|
||
|
|
if(position.x == 0.0) { // The left side of the unit square
|
||
|
|
p0 = pointA;
|
||
|
|
p1 = pointB;
|
||
|
|
p2 = pointC;
|
||
|
|
pos = position;
|
||
|
|
} else { // The right side of the unit square, use same approach but flip the geometry upside down
|
||
|
|
p0 = pointD;
|
||
|
|
p1 = pointC;
|
||
|
|
p2 = pointB;
|
||
|
|
pos = vec2(0.0, -position.y);
|
||
|
|
}
|
||
|
|
|
||
|
|
vec2 p01 = p1 - p0;
|
||
|
|
vec2 p12 = p2 - p1;
|
||
|
|
vec2 p21 = p1 - p2;
|
||
|
|
|
||
|
|
// Find the normal vector.
|
||
|
|
vec2 tangent = normalize(normalize(p12) + normalize(p01));
|
||
|
|
vec2 normal = vec2(-tangent.y, tangent.x);
|
||
|
|
|
||
|
|
// Find the vector perpendicular to p0 -> p1.
|
||
|
|
vec2 p01Norm = normalize(vec2(-p01.y, p01.x));
|
||
|
|
|
||
|
|
// Determine the bend direction.
|
||
|
|
float sigma = sign(dot(p01 + p21, normal));
|
||
|
|
float width = aLineWidth[0];
|
||
|
|
|
||
|
|
if(sign(pos.y) == -sigma) {
|
||
|
|
// This is an intersecting vertex. Adjust the position so that there's no overlap.
|
||
|
|
vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
|
||
|
|
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
|
||
|
|
} else {
|
||
|
|
// This is a non-intersecting vertex. Treat it like a mitre join.
|
||
|
|
vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
|
||
|
|
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
vColor = aColor;
|
||
|
|
}
|
||
|
|
else if(aVertType == `).concat(Ss,` && vid < 3) {
|
||
|
|
// massage the first triangle into an edge arrow
|
||
|
|
if(vid == 0)
|
||
|
|
position = vec2(-0.15, -0.3);
|
||
|
|
if(vid == 1)
|
||
|
|
position = vec2( 0.0, 0.0);
|
||
|
|
if(vid == 2)
|
||
|
|
position = vec2( 0.15, -0.3);
|
||
|
|
|
||
|
|
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
|
||
|
|
vColor = aColor;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
|
||
|
|
}
|
||
|
|
|
||
|
|
vAtlasId = aAtlasId;
|
||
|
|
vVertType = aVertType;
|
||
|
|
vIndex = aIndex;
|
||
|
|
}
|
||
|
|
`),i=this.batchManager.getIndexArray(),s=`#version 300 es
|
||
|
|
precision highp float;
|
||
|
|
|
||
|
|
// declare texture unit for each texture atlas in the batch
|
||
|
|
`.concat(i.map(function(u){return"uniform sampler2D uTexture".concat(u,";")}).join(`
|
||
|
|
`),`
|
||
|
|
|
||
|
|
uniform vec4 uBGColor;
|
||
|
|
uniform float uZoom;
|
||
|
|
|
||
|
|
in vec2 vTexCoord;
|
||
|
|
in vec4 vColor;
|
||
|
|
in vec2 vPosition; // model coordinates
|
||
|
|
|
||
|
|
flat in int vAtlasId;
|
||
|
|
flat in vec4 vIndex;
|
||
|
|
flat in int vVertType;
|
||
|
|
flat in vec2 vTopRight;
|
||
|
|
flat in vec2 vBotLeft;
|
||
|
|
flat in vec4 vCornerRadius;
|
||
|
|
flat in vec4 vBorderColor;
|
||
|
|
flat in vec2 vBorderWidth;
|
||
|
|
|
||
|
|
out vec4 outColor;
|
||
|
|
|
||
|
|
`).concat(um,`
|
||
|
|
`).concat(lm,`
|
||
|
|
`).concat(vm,`
|
||
|
|
`).concat(fm,`
|
||
|
|
|
||
|
|
vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha
|
||
|
|
return vec4(
|
||
|
|
top.rgb + (bot.rgb * (1.0 - top.a)),
|
||
|
|
top.a + (bot.a * (1.0 - top.a))
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance
|
||
|
|
// scale to the zoom level so that borders don't look blurry when zoomed in
|
||
|
|
// note 1.5 is an aribitrary value chosen because it looks good
|
||
|
|
return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d)));
|
||
|
|
}
|
||
|
|
|
||
|
|
void main(void) {
|
||
|
|
if(vVertType == `).concat(Ts,`) {
|
||
|
|
// look up the texel from the texture unit
|
||
|
|
`).concat(i.map(function(u){return"if(vAtlasId == ".concat(u,") outColor = texture(uTexture").concat(u,", vTexCoord);")}).join(`
|
||
|
|
else `),`
|
||
|
|
}
|
||
|
|
else if(vVertType == `).concat(Ss,`) {
|
||
|
|
// mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';
|
||
|
|
outColor = blend(vColor, uBGColor);
|
||
|
|
outColor.a = 1.0; // make opaque, masks out line under arrow
|
||
|
|
}
|
||
|
|
else if(vVertType == `).concat(Ht,` && vBorderWidth == vec2(0.0)) { // simple rectangle with no border
|
||
|
|
outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done
|
||
|
|
}
|
||
|
|
else if(vVertType == `).concat(Ht," || vVertType == ").concat(ya,`
|
||
|
|
|| vVertType == `).concat(on," || vVertType == ").concat(pa,`) { // use SDF
|
||
|
|
|
||
|
|
float outerBorder = vBorderWidth[0];
|
||
|
|
float innerBorder = vBorderWidth[1];
|
||
|
|
float borderPadding = outerBorder * 2.0;
|
||
|
|
float w = vTopRight.x - vBotLeft.x - borderPadding;
|
||
|
|
float h = vTopRight.y - vBotLeft.y - borderPadding;
|
||
|
|
vec2 b = vec2(w/2.0, h/2.0); // half width, half height
|
||
|
|
vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center
|
||
|
|
|
||
|
|
float d; // signed distance
|
||
|
|
if(vVertType == `).concat(Ht,`) {
|
||
|
|
d = rectangleSD(p, b);
|
||
|
|
} else if(vVertType == `).concat(ya,` && w == h) {
|
||
|
|
d = circleSD(p, b.x); // faster than ellipse
|
||
|
|
} else if(vVertType == `).concat(ya,`) {
|
||
|
|
d = ellipseSD(p, b);
|
||
|
|
} else {
|
||
|
|
d = roundRectangleSD(p, b, vCornerRadius.wzyx);
|
||
|
|
}
|
||
|
|
|
||
|
|
// use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling
|
||
|
|
// we must smooth colors inwards, because we can't change pixels outside the shape's bounding box
|
||
|
|
if(d > 0.0) {
|
||
|
|
if(d > outerBorder) {
|
||
|
|
discard;
|
||
|
|
} else {
|
||
|
|
outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if(d > innerBorder) {
|
||
|
|
vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;
|
||
|
|
vec4 innerBorderColor = blend(vBorderColor, vColor);
|
||
|
|
outColor = distInterp(innerBorderColor, outerColor, d);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
vec4 outerColor;
|
||
|
|
if(innerBorder == 0.0 && outerBorder == 0.0) {
|
||
|
|
outerColor = vec4(0);
|
||
|
|
} else if(innerBorder == 0.0) {
|
||
|
|
outerColor = vBorderColor;
|
||
|
|
} else {
|
||
|
|
outerColor = blend(vBorderColor, vColor);
|
||
|
|
}
|
||
|
|
outColor = distInterp(vColor, outerColor, d - innerBorder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
outColor = vColor;
|
||
|
|
}
|
||
|
|
|
||
|
|
`).concat(t.picking?`if(outColor.a == 0.0) discard;
|
||
|
|
else outColor = vIndex;`:"",`
|
||
|
|
}
|
||
|
|
`),o=Hy(a,n,s);o.aPosition=a.getAttribLocation(o,"aPosition"),o.aIndex=a.getAttribLocation(o,"aIndex"),o.aVertType=a.getAttribLocation(o,"aVertType"),o.aTransform=a.getAttribLocation(o,"aTransform"),o.aAtlasId=a.getAttribLocation(o,"aAtlasId"),o.aTex=a.getAttribLocation(o,"aTex"),o.aPointAPointB=a.getAttribLocation(o,"aPointAPointB"),o.aPointCPointD=a.getAttribLocation(o,"aPointCPointD"),o.aLineWidth=a.getAttribLocation(o,"aLineWidth"),o.aColor=a.getAttribLocation(o,"aColor"),o.aCornerRadius=a.getAttribLocation(o,"aCornerRadius"),o.aBorderColor=a.getAttribLocation(o,"aBorderColor"),o.uPanZoomMatrix=a.getUniformLocation(o,"uPanZoomMatrix"),o.uAtlasSize=a.getUniformLocation(o,"uAtlasSize"),o.uBGColor=a.getUniformLocation(o,"uBGColor"),o.uZoom=a.getUniformLocation(o,"uZoom"),o.uTextures=[];for(var l=0;l<this.batchManager.getMaxAtlasesPerBatch();l++)o.uTextures.push(a.getUniformLocation(o,"uTexture".concat(l)));return o},"_createShaderProgram")},{key:"_createVAO",value:v(function(){var t=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=t.length/2;var a=this.maxInstances,n=this.gl,i=this.program,s=n.createVertexArray();return n.bindVertexArray(s),Jy(n,"vec2",i.aPosition,t),this.transformBuffer=jy(n,a,i.aTransform),this.indexBuffer=Vr(n,a,"vec4",i.aIndex),this.vertTypeBuffer=Vr(n,a,"int",i.aVertType),this.atlasIdBuffer=Vr(n,a,"int",i.aAtlasId),this.texBuffer=Vr(n,a,"vec4",i.aTex),this.pointAPointBBuffer=Vr(n,a,"vec4",i.aPointAPointB),this.pointCPointDBuffer=Vr(n,a,"vec4",i.aPointCPointD),this.lineWidthBuffer=Vr(n,a,"vec2",i.aLineWidth),this.colorBuffer=Vr(n,a,"vec4",i.aColor),this.cornerRadiusBuffer=Vr(n,a,"vec4",i.aCornerRadius),this.borderColorBuffer=Vr(n,a,"vec4",i.aBorderColor),n.bindVertexArray(null),s},"_createVAO")},{key:"buffers",get:v(function(){var t=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(a){return nt(a,"Buffer")}).map(function(a){return t[a]})),this._buffers},"get")},{key:"startFrame",value:v(function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ca.SCREEN;this.panZoomMatrix=t,this.renderTarget=a,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()},"startFrame")},{key:"startBatch",value:v(function(){this.instanceCount=0,this.batchManager.startBatch()},"startBatch")},{key:"endFrame",value:v(function(){this.endBatch()},"endFrame")},{key:"_isVisible",value:v(function(t,a){return t.visible()?a&&a.isVisible?a.isVisible(t):!0:!1},"_isVisible")},{key:"drawTexture",value:v(function(t,a,n){var i=this.atlasManager,s=this.batchManager,o=i.getRenderTypeOpts(n);if(this._isVisible(t,o)&&!(t.isEdge()&&!this._isValidEdge(t))){if(this.renderTarget.picking&&o.getTexPickingMode){var l=o.getTexPickingMode(t);if(l===Rn.IGNORE)return;if(l==Rn.USE_BB){this.drawPickingRectangle(t,a,n);return}}var u=i.getAtlasInfo(t,n),f=Dr(u),c;try{for(f.s();!(c=f.n()).done;){var d=c.value,g=d.atlas,h=d.tex1,m=d.tex2;s.canAddToCurrentBatch(g)||this.endBatch();for(var p=s.getAtlasIndexForBatch(g),y=0,b=[[h,!0],[m,!1]];y<b.length;y++){var w=je(b[y],2),x=w[0],C=w[1];if(x.w!=0){var T=this.instanceCount;this.vertTypeBuffer.getView(T)[0]=Ts;var E=this.indexBuffer.getView(T);Gt(a,E);var S=this.atlasIdBuffer.getView(T);S[0]=p;var D=this.texBuffer.getView(T);D[0]=x.x,D[1]=x.y,D[2]=x.w,D[3]=x.h;var B=this.transformBuffer.getMatrixView(T);this.setTransformMatrix(t,B,o,d,C),this.instanceCount++,C||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(P){f.e(P)}finally{f.f()}}},"drawTexture")},{key:"setTransformMatrix",value:v(function(t,a,n,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=0;if(n.shapeProps&&n.shapeProps.padding&&(o=t.pstyle(n.shapeProps.padding).pfValue),i){var l=i.bb,u=i.tex1,f=i.tex2,c=u.w/(u.w+f.w);s||(c=1-c);var d=this._getAdjustedBB(l,o,s,c);this._applyTransformMatrix(a,d,n,t)}else{var g=n.getBoundingBox(t),h=this._getAdjustedBB(g,o,!0,1);this._applyTransformMatrix(a,h,n,t)}},"setTransformMatrix")},{key:"_applyTransformMatrix",value:v(function(t,a,n,i){var s,o;Ul(t);var l=n.getRotation?n.getRotation(i):0;if(l!==0){va
|
||
|
|
/*! Bundled license information:
|
||
|
|
|
||
|
|
cytoscape/dist/cytoscape.esm.mjs:
|
||
|
|
(*!
|
||
|
|
Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
|
||
|
|
Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
|
||
|
|
Licensed under The MIT License (http://opensource.org/licenses/MIT)
|
||
|
|
*)
|
||
|
|
(*!
|
||
|
|
Event object based on jQuery events, MIT license
|
||
|
|
|
||
|
|
https://jquery.org/license/
|
||
|
|
https://tldrlegal.com/license/mit-license
|
||
|
|
https://github.com/jquery/jquery/blob/master/src/event.js
|
||
|
|
*)
|
||
|
|
(*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License *)
|
||
|
|
(*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License *)
|
||
|
|
*/
|