PageSourceSearch

https://drawastickman.com/episodes/two/javascript/Path.js

js drawastickman.com collected 2026-10-01 10:28:18 UTC 5,901 bytes, 1 lines download raw bytes

1function Path(c,t,H,i){var B=new Array();var a=c;var e;var u;var l;var G;var x=3;var h=9;var j=new Array();var o=1;var n=1;var m=0;var k=0;var w=0;var z=0;var r=t;var g=new Array();var f=new Array();var q;var p;var s=0;var C=H;var d;var A;var y;var b;var E=i;this.findIndexOf=function(K,M){if(!Array.indexOf){for(var L=0;L<K.length;L++){if(K[L]==M){return L}}return -1}else{return K.indexOf(M)}};var I=function(P,N){var O=0;var M=0;if(w>0){O=B[w-1].getX();M=B[w-1].getY();if(P<O+x&&P>O-x&&N<M+x&&N>M-x){return false}else{while(P>O+h||P<O-h||N>M+h||N<M-h){var L=Math.round((P-O)*0.5);var K=Math.round((N-M)*0.5);if(L>0&&L>h){L=h}if(L<0&&L<-h){L=-h}if(K>0&&K>h){K=h}if(K<0&&K<-h){K=-h}var R=O+L;var Q=M+K;J(R,Q,true);O=R;M=Q}}}J(P,N,false);return true};var F=this.quickDrawNode=function(N,M){N=Math.round(N);M=Math.round(M);if(s>0){if(Math.abs(q-N)<5&&Math.abs(p-M)<5){return}}g.push(N);f.push(M);s++;if(s>1){var L=["M",Math.round(E.zoomX(q))," ",Math.round(E.zoomY(p)),"L",Math.round(E.zoomX(N))," ",Math.round(E.zoomY(M))].join("");var K=a.path(L)}else{var L=["M",Math.round(E.zoomX(N))," ",Math.round(E.zoomY(M)),"L",Math.round(E.zoomX(N+3))," ",Math.round(E.zoomY(M+1))].join("");var K=a.path(L)}K.attr("stroke-width",E.zoomSize(C));K.attr("stroke",r);j.push(K);z++;q=N;p=M};var v=this.createQuickNode=function(L,K){if(s>0){if(Math.abs(q-L)<5&&Math.abs(p-K)<5){return}}g.push(L);f.push(K);s++;q=L;p=K};this.finalizePath=function(){for(var K=0;K<s;K++){I(g[K],f[K])}};var J=function(N,M,L){var K=new Node(N,M,this,L);if(w==0){u=new Rectangle(N,M,N,M);l=K}else{u.addPoint(N,M);if(K.getY()>l.getY()){l=K}}B.push(K);w++};this.clearDisplay=function(){if(z>0){for(var K=0;K<z;K++){j[K].remove()}j=new Array();z=0}if(e!=null){e.remove();e=null}};this.draw=function(N,K,P){if(z>0){for(var O=0;O<z;O++){j[O].remove()}j=new Array();z=0}if(K==null){K=0}if(P==null){P=0}if(w>0){if(N==null){var M=["M",E.zoomX((B[0].getX()+K)*o+m)," ",E.zoomY((B[0].getY()+P)*n+k)];if(w==1){M.push("L");M.push(E.zoomX((B[0].getX()+2+K)*o+m));M.push(" ");M.push(E.zoomY((B[0].getY()+3+P)*n+k))}else{for(var L=1;L<w;L++){if(B[L].isExtraNode()==false){M.push("L");M.push(E.zoomX((B[L].getX()+K)*o+m));M.push(" ");M.push(E.zoomY((B[L].getY()+P)*n+k))}}}}else{var M=["M",E.zoomX((N.distortPointX(B[0].getX(),B[0].getY())+K)*o+m)," ",E.zoomY((N.distortPointY(B[0].getX(),B[0].getY())+P)*n+k)];if(w==1){M.push("L");M.push(E.zoomX((N.distortPointX(B[0].getX()+2,B[0].getY()+3)+K)*o+m));M.push(" ");M.push(E.zoomY((N.distortPointY(B[0].getX()+2,B[0].getY()+3)+P)*n+k))}else{for(var L=1;L<w;L++){if(B[L].isExtraNode()==false){M.push("L");M.push(E.zoomX((N.distortPointX(B[L].getX(),B[L].getY())+K)*o+m));M.push(" ");M.push(E.zoomY((N.distortPointY(B[L].getX(),B[L].getY())+P)*n+k))}}}}if(e==null){e=a.path(M.join(""));e.attr("stroke-width",E.zoomSize(C));e.attr("stroke",r)}else{e.attr({path:M,"stroke-width":E.zoomSize(C)})}}};this.drawLastPoint=function(){if(w>1){var O=w-1;var K=z+1;for(var N=K;N<=O;N++){var M="M"+E.zoomX(B[N-1].getX())+" "+E.zoomY(B[N-1].getY());M+="L"+E.zoomX(B[N].getX())+" "+E.zoomY(B[N].getY());var L=a.path(M);L.attr("stroke-width",E.zoomSize(C));L.attr("stroke",r);j.push(L);z++}}else{if(w==1){var M="M"+E.zoomX(B[0].getX())+" "+E.zoomY(B[0].getY());M+="L"+E.zoomX(B[0].getX()+1)+" "+E.zoomY(B[0].getY()+1);var L=a.path(M);L.attr("stroke-width",E.zoomSize(C));L.attr("stroke",r);j.push(L);z++}}};this.getLowestNode=function(){return l};this.getNumNodes=function(){return s};this.getSecondLowestNode=function(){var K=this.findIndexOf(B,l);var N=l.getY();var L=false;for(var M=K;M<w;M++){if(L==false){if(B[M].getY()<N-G){L=true}}else{if(B[M].getY()>N+G*0.5){return B[M]}}}L=false;for(var M=K;M>=0;M--){if(L==false){if(B[M].getY()<N-G){L=true}}else{if(B[M].getY()>N+G*0.5){return B[M]}}}return null};this.getRect=function(){return u};this.getNodesInRow=function(K,N){var M=new Array();if(u.bottom>=K&&u.top<=N){for(var L=0;L<w;L++){if(B[L].getY()>=K&&B[L].getY()<=N){M.push(B[L])}}}return M};this.highlightNodes=function(){for(var K=0;K<w;K++){var L=a.circle(B[K].getX(),B[K].getY(),2,2,0).attr({fill:"#ff0",opacity:0.5})}};this.setScale=function(N,M,L,K){m=N;k=M;o=L;n=K};this.removeDeletedNodes=function(){var M=Array();var L=0;for(var K=0;K<w;K++){if(B[K].isMarkedForDelete()==false){M.push(B[K]);L++}}B=M;w=L};this.getNodeClosestToPoint=function(V,R,M,Q,L){if(u.left>M||u.right<R||u.top>L||u.bottom<Q){return null}var N=null;var U=0;var T=0;for(var S=0;S<w;S++){var P=B[S].getX();var O=B[S].getY();if(P<=M&&P>=R&&O<=L&&O>=Q){var K=P-V.x;var W=O-V.y;
1if(Math.abs(K)+Math.abs(W)<Math.abs(U)+Math.abs(T)||N==null){U=K;T=W;N=new Point(P,O)}}}return N};this.getDataForJSON=function(){var K=new Array();var M=0;for(var L=0;L<w;L++){if(B[L].isExtraNode()==false){K[M]=Math.round(B[L].getX());K[M+1]=Math.round(B[L].getY());M+=2}}return K};this.setDataFromJSON=function(O,N){var L=0;var M=O.length;for(var K=0;K<M;K+=2){if(N==true){I(-O[K],O[K+1])}else{I(O[K],O[K+1])}}};this.redrawSlowly=function(L,K,M){d=0;A=K;y=M;b=L;D()};var D=function(){d++;if(d>=w){setTimeout(b,120)}else{F(B[d].getX()+A,B[d].getY()+y);setTimeout(D,20)}};this.getNodes=function(){return B};this.move=function(K,M){for(var L=0;L<w;L++){B[L].move(K,M)}u.left+=K;u.right+=K;u.top+=M;u.bottom+=M};this.deleteNodes=function(){B=new Array();w=0};this.sendToBack=function(){for(var K=0;K<z;K++){j[K].toBack()}};this.getLineOnScreen=function(){return e};this.scaleStrokeWidth=function(K){C=C*K};this.getPrintExportData=function(K,O,N){var L=new Array();for(var M=0;M<w;M++){if(B[M].isExtraNode()==false){L.push(Math.round(B[M].getX()*K+O));L.push(Math.round(B[M].getY()*K+N))}}var P=L.join();return P};this.cleanUp=function(){for(var K=0;K<z;K++){j[K].cleanUp()}B=null;a=null;e=null;u=null;l=null;G=null;x=null;h=null;j=null;o=null;n=null;m=null;k=null;w=null;z=null;r=null;g=null;f=null;q=null;p=null;s=null;C=null;d=null;A=null;y=null;b=null;E=null}};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.