0x792654e8…f200sent to0x99a9b7c1…b069·#18,928,204·view on Etherscan
///1
/*
* CYTOGRAPHIA by Golan Levin (2021-2024)
* An Interactive Neoincunabulum of Xenocytology
*
* ACKNOWLEDGEMENTS
* This project incorporates or adapts the following code, under the specified licenses:
* "p5.js v.1.0.0" by The Processing Foundation: https://p5js.org/ (GPL)
* "Fortune's Voronoi" (in D3) by Mike Bostock: https://github.com/d3/d3-delaunay (ISC, Copyright 2021 Mapbox)
* "GLSL Blend Modes" by Jamie Owen: https://github.com/jamieowen/glsl-blend (MIT)
* "GLSL Value Noise" by Inigo Quilez: https://www.shadertoy.com/view/lsf3WH (MIT)
* "2D Perlin Noise" by Stefan Gustavson: https://github.com/stegu/webgl-noise/blob/master/src/classicnoise2D.glsl (MIT)
* "ImageJ (Distance Transform)" by NIH: https://github.com/imagej/ImageJ/blob/master/ij/process/BinaryInterpolator.java (Public Domain)
* "ofPolyline" in openFrameworks: https://github.com/openframeworks/openFrameworks/tree/master/libs/openFrameworks/graphics (MIT)
* "webgl-lines" by Matt DesLauriers: https://mattdesl.github.io/webgl-lines/expanded/gl-line-2d.js (MIT)
*/
'use strict';
let myABRandom;let myABFeatures;
const T=true;const F=false;
const PINF=Number.POSITIVE_INFINITY;const NINF=Number.NEGATIVE_INFINITY;
const ST0=0,ST1=1,ST2=2,ST3=3,ST4=4,ST5=5,ST6=6,ST7=7,ST8=8,ST9=9,ST10=10,ST11=11,ST12=12,ST13=13,ST14=14,ST15=15,ST16=16,ST17=17;
const STR_NO=-1;const STR_BK=0;const STR_WH=1;const FIL_NO=-1;const FIL_BK=0;const FIL_WH=1;const PARTY_STYLE=-1;
const PI2=Math.PI*2;
const LLSP=79./128.;const SPR_K=38./128.;
const DAMPING=123./128.;const NUDGE=1./8192.;let REST_L=10;
let MAXSP=REST_L*0.3125;let MAXSP2=MAXSP*MAXSP;
let MINSPRD=REST_L/128.;let MINSPRD2=(MINSPRD*MINSPRD);
const MaxNPs=16000;const RENDER_MODE_PAPER=0;const RENDER_MODE_CANVAS=1;
let renderMode=RENDER_MODE_PAPER;
const nSecsToFreeze=60;let TMP=1.;
let bTemperatureCooling=F;let initFreezeT=-1e5;
let myFrmCnt=0;let lastFrameTime=0;
let myMillis=0.;let FPS=30;
let d3Delaunay;let d3Voronoi;
let d3Data=[];let myPs=[];let mySs=[];
let myFlocks=[];
let StSh;let PHASH="";let CHASH="";let CNOISEED=0;
const NFOLIOS=16;let folioHs=[];let curFolio=0;
const BDM=840;const SHW=256;const SHH=256;
const W0=.333;const W1=1;const W2=2.236;const W3=4;
const MOUSE_REPULSION=-5;const MOUSE_F_POW=.75;const MOUSE_F_RAD_PCT=.05;const MOUSE_F_RAD_T=100;let MOUSINFL=-0.25;
const N_INIT_INTERIOR_PTS=700;let nInteriorPoints=N_INIT_INTERIOR_PTS;
let nMaskPoints=0;let globalOccupancy=1;let HOVER_ITEMS;
const P_SIZE_CONSTANT=0;const P_SIZE_SPEEDBASED=1;const P_SIZE_VARIEGATED=2;
let maskR=.4;
let designBgCol='AntiqueWhite';
let meanPaperColor=255;let avgPapCol=255;
let zScale=1;let debugAskTime=0;
let bZoom=F;let bShoDbg=F;
const autoPlayMs=120000;
let theBB={L:PINF,T:PINF,R:NINF,B:NINF};
const MAX_N_LETTERS=10;
let bDoMF=T;let bApplyFlockF=T;let bDoLetters=T;
let nxtL='A';let glyphSet=[];
let myDesignCanvas;let bSaveScreencapture=F;
const EXPSZ=4096;
let ogI,GFXP5,GFXP5C;let myStyPolyl,wheelStylePairs,loopStylePairs;
const WHEEL_MODE_PARTY=0;const WHEEL_MODE_MONOCULTURE=1;const WHEEL_MODE_HALFMONOCULTURE=2;
let imper;let selectedSiteIndex=-1;
let bDisableSiteWarping=F;let bEnableSpringPhysics=T;let bAddNoiseToBlobPolyline=T;
let bApplyWaveToSpineRestLengths=T;let bRestoreCenterSiteToCenter=T;let bRestoreSpineToVertical=T;
let prevZeroLocation=0;let zeroOffsetIndex=0;let bFirstTimeForMask=T;let bBlankCell=F;
let twist,bloat,bendx,bendy;let maxBloat,minBloat;
let closenessThreshForSprings,nSubdivsToDo;
let unexpectedBlobSiteProbability,rotationalRestoreForce;
let blobContourSpringK,blobContourDamping;
let X0,X1,Y0,Y1,CX,CY;let nSpineSites,nSitePairs;
let SHMA=100;let CONT_MODE=1;
const CONT_MODE_IMPLICIT_SPINES=0;const CONT_MODE_IMPLICIT_RADIAL=1;const CONT_MODE_AMORPHOUS=2;
let sitePVecs=[];
let springPairings=[];
let sitePs=[];
let siteSprings=[];
let niceSiteIds=[];
let radialTipIndices=[];
let SITE_FOR_SPRINGS_AND_BLOB=1;
let SITE_FOR_SPRINGS_ONLY=-1;
let centralSiteId=0;
let deferredParticleTargetStructures=[];
let deferredStructures=[];
let R20K=[];
let dlnyTris=[];let uniqDlnyEs=[];
let IMPL_DLNY_EPS=1./1048576.;
let rawBlobPVectorArrayContainer;
let resampledBlobPolyline,resampNoiBlobPolyl;
let fadeInPhysics=0;let fadeInPhysicsNFrames=100;
let dtInG,dtOutG,dtInBf,dtOutBf;
const dtW=256;const dtH=256;const dtWm1=dtW-1;const dtHm1=dtH-1;
let GrabStrcId=-1;let GrabPid=-1;
let mousePressedTime=0;let mouseReleasedTime=0;
let shPaper,shBlur,shComp,ogP,ogS,ogT,ogB,ogC;
let bMadeRevTxt=F;let uBlurRadius=0.75;let uEmbossAmount=0.6;
let myShVert="",frag_comp="",frag_blur="",frag_paper="";
let ogForStamp;let stampW=256;
let stampTB4Bad=F;
let nRetries=0;
//======
function setup(){
CHASH=PHASH=tokenData.hash;
myABRandom=new Random();
frameRate(120);
makeFolios();makeAsmSys();makeOGs(SHW,SHH);makeShs();
myDesignCanvas=createCanvas(SHW,SHW);
myStyPolyl=new StyledPolylineRenderer();
makeCell(CHASH);windowResized();}
function CV(x,y,z=0){return createVector(x,y,z)}
function CG(w,h,t){return createGraphics(w,h,t)}
function Rd(d){return radians(d)}
function Cs(v,a,b){return constrain(v,a,b)}
function Ro(a){return round(a)}
function Sb(a,b){return p5.Vector.sub(a,b)}
function Ad(a,b){return p5.Vector.add(a,b)}
function makeFolios(){folioHs=[],curFolio=0,resetRnd(PHASH);for(let o=0;o<NFOLIOS;o++)if(0==o)folioHs[o]=CHASH;else{let e=getPseudoRandomHash();folioHs[o]=e.hash}}
function initPaper(){bMadeRevTxt=F;let e=zScale;zScale=1,resetRnd(CHASH),updatePapU(),resetRnd(CHASH),designOffscreenGraphicsForReverseText(),resetRnd(CHASH),designOffscreenGraphicsForPaper(),makePapBg(),resetRnd(CHASH),makeAsmAlph(),zScale=e;createStampImage();}
function makeOGs(SW,SH){ogC=CG(SW,SH,WEBGL);ogP=CG(SW,SH,WEBGL);ogB=CG(SW,SH,WEBGL);ogT=CG(SW,SH);ogS=CG(SW,SH);ogI=CG(SW,SH);}
function makeShs(){myShVert=atob("YXR0cmlidXRlIHZlYzMgYVBvc2l0aW9uOyBhdHRyaWJ1dGUgdmVjMiBhVGV4Q29vcmQ7IHZhcnlpbmcgdmVjMiB2VGV4Q29vcmQ7IHZvaWQgbWFpbigpIHsgICB2VGV4Q29vcmQgPSBhVGV4Q29vcmQ7ICAgdmVjNCBwb3NpdGlvblZlYzQgPSB2ZWM0KGFQb3NpdGlvbiwgMS4wKTsgICBwb3NpdGlvblZlYzQueHkgPSBwb3NpdGlvblZlYzQueHkgKiAyLjAgLSAxLjA7ICAgZ2xfUG9zaXRpb24gPSBwb3NpdGlvblZlYzQ7IH0=");
frag_comp="#define V3 vec3\n#define F float\n#define R return\n#define U uniform\nprecision mediump F;varying vec2 vTexCoord;U F uZoomScale;U F uBiasC;U F uBiasL;U F uReverseTextAmount;U F uIllLit;U F uIllG;U sampler2D texPap;U sampler2D texRevTxt;F blOverlay(F base,F bl){R base<0.5?(2.*base*bl):(1.-2.*(1.-base)*(1.-bl));}V3 blOverlay(V3 base,V3 bl){R V3(blOverlay(base.r,bl.r),blOverlay(base.g,bl.g),blOverlay(base.b,bl.b));}F blColorBurn(F base,F bl){R(bl==0.)?bl:max((1.-((1.-base)/bl)),0.);}V3 blColorBurn(V3 base,V3 bl){R V3(blColorBurn(base.r,bl.r),blColorBurn(base.g,bl.g),blColorBurn(base.b,bl.b));}F blColorDodge(F base,F bl){R(bl==1.)?bl:min(base/(1.-bl),1.);}V3 blColorDodge(V3 base,V3 bl){R V3(blColorDodge(base.r,bl.r),blColorDodge(base.g,bl.g),blColorDodge(base.b,bl.b));}F blSoftLight(F base,F bl){R(bl<0.5)?(2.*base*bl+base*base*(1.-2.*bl)):(sqrt(base)*(2.*bl-1.)+2.*base*(1.-bl));}V3 blSoftLight(V3 base,V3 bl){R V3(blSoftLight(base.r,bl.r),blSoftLight(base.g,bl.g),blSoftLight(base.b,bl.b));}V3 blSoftLight(V3 base,V3 bl,F opacity){R(blSoftLight(base,bl)*opacity+base*(1.-opacity));}F blCustom(F base,F bl){R(bl<0.5)?blColorBurn(base,(2.*bl)):mix(blOverlay(base,bl),blColorDodge(base,(2.*(bl-0.5))),0.);}V3 blCustom(V3 base,V3 bl){R V3(blCustom(base.r,bl.r),blCustom(base.g,bl.g),blCustom(base.b,bl.b));}void main(){vec2 paperCoord =vec2(0.5+(vTexCoord.x-0.5)/uZoomScale,0.5+(vTexCoord.y-0.5)/uZoomScale);V3 bg3=texture2D(texPap,paperCoord).rgb;V3 fg3=V3(0.5,0.5,0.5);bg3.r=pow(bg3.r,uBiasL);bg3.g=pow(bg3.g,uBiasL);bg3.b=pow(bg3.b,uBiasL);V3 newGolan=blCustom(bg3,fg3);V3 newCoBur=blColorBurn(bg3,fg3);V3 new1=mix(newGolan,newCoBur,uBiasC);vec2 vTexCoordFlip=vec2(vTexCoord.x,1.-vTexCoord.y);V3 il3=V3(1.,1.,1.);il3=pow(il3,V3(uIllG,uIllG,uIllG));new1.r=mix(new1.r,il3.r+(1.-il3.r)*uIllLit,1.-il3.r);new1.g=mix(new1.g,il3.g+(1.-il3.g)*uIllLit,1.-il3.g);new1.b=mix(new1.b,il3.b+1.05*(1.-il3.b)*uIllLit,1.-il3.b);V3 new2=new1;vec2 vAsemicCoord=vec2(0.5+(vTexCoord.x-0.5)/uZoomScale,0.5+((1.-vTexCoord.y)-0.5)/uZoomScale);F rta=texture2D(texRevTxt,vAsemicCoord).a;new2=blSoftLight(new1,V3(0.,0.,0.),rta*uReverseTextAmount);gl_FragColor=vec4(new2.r,new2.g,new2.b,1.);}";
frag_blur="#define V2 vec2\n#define T2 texture2D\n#define F float\n#define U uniform\nprecision mediump F;varying V2 vTexCoord;U sampler2D t0;U V2 uTexelSize;U F uBlur;U F uAlpha;U F uPhase;void main(){ V2 uv=vTexCoord;uv=V2(uv.x,1.- uv.y);F dx1=uTexelSize.x*uBlur;F dy1=uTexelSize.y*uBlur;F dx2=uTexelSize.x*uBlur*2.;F dy2=uTexelSize.y*uBlur*2.;F tx=0.;tx+=T2(t0,uv+V2(-dx2,-dy2)).a;tx+=T2(t0,uv+V2(-dx1,-dy2)).a*4.;tx+=T2(t0,uv+V2(0.,-dy2)).a*6.;tx+=T2(t0,uv+V2(dx1,-dy2)).a*4.;tx+=T2(t0,uv+V2(dx2,-dy2)).a;tx+=T2(t0,uv+V2(-dx2,-dy1)).a*4.;tx+=T2(t0,uv+V2(-dx1,-dy1)).a*16.;tx+=T2(t0,uv+V2(0.,-dy1)).a*24.;tx+=T2(t0,uv+V2(dx1,-dy1)).a*16.;tx+=T2(t0,uv+V2(dx2,-dy1)).a*4.;tx+=T2(t0,uv+V2(-dx2,0.)).a*6.;tx+=T2(t0,uv+V2(-dx1,0.)).a*24.;tx+=T2(t0,uv).a*36.;tx+=T2(t0,uv+V2(dx1,0.)).a*24.;tx+=T2(t0,uv+V2(dx2,0.)).a*6.;tx+=T2(t0,uv+V2(-dx2,dy1)).a*4.;tx+=T2(t0,uv+V2(-dx1,dy1)).a*16.;tx+=T2(t0,uv+V2(0.,dy1)).a*24.;tx+=T2(t0,uv+V2(dx1,dy1)).a*16.;tx+=T2(t0,uv+V2(dx2,dy1)).a*4.;tx+=T2(t0,uv+V2(-dx2,dy2)).a;tx+=T2(t0,uv+V2(-dx1,dy2)).a*4.;tx+=T2(t0,uv+V2(0.,dy2)).a*6.;tx+=T2(t0,uv+V2(dx1,dy2)).a*4.;tx+=T2(t0,uv+V2(dx2,dy2)).a;tx/=256.;tx*=uAlpha;tx*=0.85+0.15*cos(uv.y*5.*3.14159+uPhase);tx*=0.75+0.25*sin(uv.x*2.3*3.14159+uPhase);gl_FragColor=vec4(0.,0.,0.,tx);}";
frag_paper="#define F float\n#define V2 vec2\n#define U uniform\n#define R return\nprecision mediump float;varying V2 vTexCoord;U V2 uNoiOff;U F uGLNoi;U F uCNoi;U F uLFF;U F uLFB;U F uLFA;U F uSCC;U F uHV;U F uSBP;U F uFxS;U F uFxT;U F uFxA;U F uMil;F map(F value,F min1,F max1,F min2,F max2){R min2+(value-min1)*(max2-min2)/(max1-min1);}F expSg(F x,F a,F b){const F epsilon=0.000001;a=1.-clamp(a,epsilon,1.-epsilon);F y=0.;F w=max(0.,min(1.,x-(b-0.5)));if(w<=0.5){y=(pow(2.*w,1./a))/2.;}else{y=1.-(pow(2.*(1.-w),1./a))/2.;} R(y);}F elW(F x,F a,int n){const F epsilon=0.00001;a=clamp(a,epsilon,1.-epsilon);F y=0.;F pwn=F(n)*2.;if(x<=a){y=(1./a)*pow(pow(a,pwn)-pow(abs(x-a),pwn),1./pwn);}else{y=(1./(1.-a))*pow(pow(1.-a,pwn)-pow(x-a,pwn),1./pwn);}R y;}F rnd2(in V2 st){R fract(sin(dot(st.xy,V2(12.9898,78.233)))*43758.5453123);}F rnd2(in F x,in F y){R fract(sin(dot(V2(x,y),V2(12.9898,78.233)))*43758.5453123);}F randomGaussian(in V2 st,in F mean,in F sdv){const int N=8;const F n2=(F(N))/2.;F x=st.x;F y=st.y;F sum=0.;for(int i=0;i<N;i++){F xp=rnd2(x,y);F yp=rnd2(y,x);sum+=rnd2(xp,yp);x=xp;y=yp;}sum=(sum-n2)/n2*sdv+mean;R sum;}F scos(in F f){R 0.5*(1.-cos(f*3.14159265359));}F p5PN(F x,F y,int noct,F falloff){F xif=floor(x);F yif=floor(y);F xf=fract(x);F yf=fract(y);F rxf,ryf;F n1,n2;F ampl=0.5;F r=0.;for(int o=0;o<10;o++){if(o>=noct){break;}rxf=scos(xf);ryf=scos(yf);n1=rnd2(xif,yif);n1+=rxf*(rnd2(xif+1.,yif)-n1);n2=rnd2(xif,yif+1.);n2+=rxf*(rnd2(xif+1.,yif+1.)-n2);n1+=ryf*(n2-n1);r+=n1*ampl;ampl*=falloff;xif*=2.;xf*=2.;yif*=2.;yf*=2.;if(xf>=1.){xif++;xf--;}if(yf>=1.){yif++;yf--;}}R r;}F hash(V2 p){R 2.*fract(sin(dot(p,V2(12.9898,78.233)))*43758.5453)-1.;}F iqNoise(in V2 p){V2 i=floor(p);V2 f=fract(p);V2 u=f*f*(3.-2.*f);R mix(mix(hash(i+V2(0.,0.)),hash(i+V2(1.,0.)),u.x),mix(hash(i+V2(0.,1.)),hash(i+V2(1.,1.)),u.x),u.y);}F iqPN(in V2 p,int noct,F falloff){V2 uv=p;mat2 m=mat2(1.6,1.2,-1.2,1.6);F ampl=falloff;F f=0.;for(int o=0;o<10;o++){if(o>=noct){break;}f+=iqNoise(uv)*ampl;ampl*=falloff;uv=m*uv;}f=0.5+0.5*f;R f;}F sfseg(V2 p,V2 v,F t0,F t1){R distance(p,clamp(dot(p,v),t0,t1)*v);}F sfarc(V2 p,F t0,F t1){F t=atan(p.y,p.x)/6.28318531;F tt=mod(t-t0,1.)+t0;if((t0<=t1&&tt<=t1)||(t1<=t0&&t1<=tt-1.)){R abs(length(p)-1.);}F t0twoPi=6.28318531*t0;F t1twoPi=6.28318531*t1;V2 q1=V2(cos(t0twoPi),sin(t0twoPi));V2 q2=V2(cos(t1twoPi),sin(t1twoPi));R min(distance(p,q1),distance(p,q2));}F arc(V2 p,F cx,F cy,F r,F t0,F t1){F ud=1e30;F s=sign(t1-t0);F circumf=r*6.28318531;F L=circumf*abs(t1-t0);F tt=L/circumf;if(tt>0.){V2 pp=(p-V2(cx,cy))/r;ud=r*sfarc(pp,t0,t0+s*tt);}R ud;}F seg(V2 p,F x0,F y0,F x1,F y1){F ud=1e30;V2 v=V2(x1,y1)-V2(x0,y0);F L=length(v);if(L>0.){ud=sfseg(p-V2(x0,y0),v/L,0.,L);}R ud;}F genMark(V2 p){F ud=1e30;ud=min(ud,arc(p,0.,3.,1.,0.,0.5));ud=min(ud,arc(p,0.,1.875,1.,0.5,1.));ud=min(ud,seg(p,1.,1.875,1.,2.1));ud=min(ud,seg(p,-1.,3.,-1.,1.875));ud=min(ud,seg(p,-0.1,2.,1.,2.));ud=min(ud,seg(p,0.,2.,0.,3.));ud=min(ud,seg(p,-0.1,3.,0.1,3.));R ud;}void main(){V2 Co=vTexCoord;F rbase=1.000;F gbase=0.945;F bbase=0.850;V2 cof1=Co-V2(uNoiOff.x,uNoiOff.y);V2 cof2=Co+V2(uNoiOff.x,uNoiOff.y);F lx=uNoiOff.x+Co.x*uLFA;F ly=uNoiOff.y+Co.y;F LFN=p5PN(lx,ly,7,uLFF);F gray=map(LFN,0.,1.,uLFB,1.);gray+=randomGaussian(cof1,0.,uGLNoi);F h=uSCC;F shbp=uSBP;F rout=gray*rbase;F gout=gray*gbase;F bout=gray*bbase;rout*=map(pow(LFN,0.1),0.,1.,0.9*h,1.);gout*=map(pow(LFN,0.2),0.,1.,0.8*h,1.);bout*=map(pow(LFN,shbp),0.,1.,0.55*h,1.);if(uMil>0.){F sinCXP=sin(uMil*1000.);F sinFreqX=10.+rnd2(uMil,sinCXP);F sinCoordX=abs(sin(sinCXP+Co.x*sinFreqX));F smX=(pow(sinCoordX,5.)-0.5*pow(sinCoordX,500.));F milling=uMil*smX;rout-=milling*1.;gout-=milling*1.5;bout-=milling*2.5;}F hva=uHV;F exa=iqPN(V2(Co.x*hva,uNoiOff.y),3,0.55);F eya=iqPN(V2(Co.y*1.,uNoiOff.x),3,0.55);F rew=map(elW(Co.x,exa,4),0.,1.,0.15,1.);F gew=map(elW(Co.x,exa,3),0.,1.,0.1,1.);F bew=map(elW(Co.x,exa,2),0.,1.,0.05,1.);rew*=map(elW(Co.y,eya,3),0.,1.,0.89,1.);gew*=map(elW(Co.y,eya,2),0.,1.,0.78,1.);bew*=map(elW(Co.y,eya,1),0.,1.,0.67,1.);rout*=rew;gout*=gew;bout*=bew;F foxx=(Co.x+uNoiOff.y)*uFxS;F foxy=(Co.y+uNoiOff.x)*uFxS;F foxNoise =iqPN(V2(foxx,foxy),7,0.6);F foxNoiseNoise =p5PN(foxy*1.,foxx*1.,5,0.45);F fbr=0.8;F fbg=0.5;F fbb=0.2*(1.-foxNoiseNoise);F fxNR=expSg(foxNoise,0.965,uFxT);F fxNG=expSg(foxNoise,0.955,uFxT+0.07);F fxNB=expSg(foxNoise,0.95,uFxT+0.1);fxNR=map(fxNR,0.,1.,fbr,1.);fxNG=map(fxNG,0.,1.,fbg,1.);fxNB=map(fxNB,0.,1.,fbb,1.);F A=map(pow(foxNoiseNoise,uFxA),0.,1.,0.05,1.);F B=1.-A;rout=A*rout+B*(rout*fxNR);gout=A*gout+B*(gout*fxNG);bout=A*bout+B*(bout*fxNB);F dark=min(rout,min(gout,bout));F roff=uCNoi*pow(1.-dark,0.9975)*(rnd2(cof2.yx)-0.5);F goff=uCNoi*pow(1.-dark,0.995)*(rnd2(cof1.xy)-0.5);F boff=uCNoi*pow(1.-dark,0.9925)*(rnd2(cof2.xy)-0.5);rout+=roff;gout+=goff;bout+=boff;F FW=clamp(0.02*uNoiOff.y,0.01,0.05);F xform_s=30.;V2 p=xform_s*V2(Co.x,1.-Co.y);p.x-=2.;p.y-=0.;F sdf=genMark(p);sdf=max(0.,sdf-FW);F markCol=exp(sdf*-30.);F wmx=Co.x*140.+uNoiOff.y;F wmy=Co.y*140.+uNoiOff.x;F wmNoise=p5PN(wmx,wmy,5,0.55);markCol*=0.75*clamp((wmNoise-0.2)*3.,0.,1.); rout+=markCol*0.04;gout+=markCol*0.05;bout+=markCol*0.06;gl_FragColor=vec4(rout,gout,bout,1.);}";
shComp=ogC.createShader(myShVert,frag_comp);shBlur=ogB.createShader(myShVert,frag_blur);shPaper=ogP.createShader(myShVert,frag_paper);}
function makeCell(e){clearSettableGlobals(),setupDT(),initRandomSeed(e),initStyleSheet(),initPaper(),initContour(),initAllPhysics(),tryToInitializeStructures(),initFreePs(),clearGrabbedItems()}
function reset(){makeCell(CHASH);}
function getUnofficialNewCell(bB){bBlankCell=bB;makeCell((getPseudoRandomHash()).hash);}
function clearSettableGlobals(){
TMP=1.;bTemperatureCooling=F;initFreezeT=-1e5; if(nRetries==0){myABFeatures=undefined;}
myFrmCnt=lastFrameTime=myMillis=0;FPS=30;CNOISEED=0;
StSh=null;d3Delaunay=null;d3Voronoi=null;
d3Data=[];myPs=[];mySs=[];myFlocks=[];
nInteriorPoints=N_INIT_INTERIOR_PTS;
globalOccupancy=1;nMaskPoints=0;renderMode=RENDER_MODE_PAPER;
HOVER_ITEMS=null;maskR=0.4;theBB={L:PINF,T:PINF,R:NINF,B:NINF};
bDoMF=T;bApplyFlockF=T;imper=null;StSh=null;
selectedSiteIndex=-1;bDisableSiteWarping=F;
bEnableSpringPhysics=bAddNoiseToBlobPolyline=bApplyWaveToSpineRestLengths=T;
bRestoreCenterSiteToCenter=bRestoreSpineToVertical=T;
prevZeroLocation=zeroOffsetIndex=0;MOUSINFL=-0.25;
bFirstTimeForMask=T;nxtL='A';}
//======
function printSysInfo(){
let fs=(StSh.bEnableRingsOrHairs)?"1":"0";
fs+=((StSh.bDrawPs)?"1":"0")+((StSh.bDrawVs)?"1":"0")+((StSh.bDrawBs)?"1":"0");fs+=((StSh.bUseVSh)?"1":"0");
let t=("===========\n");
t+=("CYTOGRAPHIA\n");
t+=("An Interactive Neoincunabulum of Xenocytology\n");
t+=("By Golan Levin, 2021-2024 - Created with p5.js\n\n");
t+=("Diagnostic Information:\n");
t+=("System: "+navigator.userAgent);
t+=("\nPHASH: "+PHASH+"\nCHASH: "+CHASH);
t+=("\n\nClade: "+myABFeatures.Clade);
t+=("\nIlea: "+myABFeatures.Ilea);
t+=("\nOrnare: "+myABFeatures.Ornare);
t+=("\nPhalor: "+myABFeatures.Phalor);
t+=("\nVestis: "+myABFeatures.Vestis);
t+=("\nDermis: "+myABFeatures.Dermis);
t+=("\nIndica: "+myABFeatures.Indica);
t+=("\n\nmyFrmCnt: "+myFrmCnt);
t+=("\nmyMillis: "+int(myMillis));
t+=("\ntemperature: "+nf(TMP,1,3));
t+=("\nnParticles: "+myPs.length);
t+=("\nrenderMode: "+renderMode);
t+=("\nflags: "+fs);
t+=("\nnRetries: "+nRetries);
t+=("\nuser-defined: "+bBlankCell);
t+=("\nwindowWidth: "+windowWidth);
t+=("\nzScale: "+nf(zScale,1,3));
t+=("\nFPS: "+nf(FPS,1,2)+"\n");print(t);}
function printKeys(){let t=("\n");
t+=("[ ]\n[i]\n[h]\n[r]\n[P]\n[S]\n[↑↓]\n\n\n[o]\n[0-9]\n");
t+=("[g]\n[.]\n\n\n[z]\n[x]\n[c]\n[v]\n[b]\n[L]");return(t)}
function printHelp(){let t=("\n");
t+=("Pause one minute\nPrint info in console\nDisplay help\n");
t+=("Reset cell\nExport PNG\nExport SVG\n");
t+=(" Zoom\n\n\nBlank\n Features\n");
t+=("Grow\nParticles\n\n\nPaper\nBorders\n");
t+=("Particles\nCells\nBlobs\nLines");return(t)}
function printTitles(){let t=("CYTOGRAPHIA Key Commands\n\n\n\n\n\n\n\n\n");
t+=("Sandbox\n\n\n\n\n\nToggles\n\n\n\n\n\n\n\n");
t+=("FPS: "+nf(FPS,1,2));return(t)}
//======
function windowResized(){let e=min(window.innerWidth,window.innerHeight);resizeCanvas(e,e),ogI.resizeCanvas(e,e),myStyPolyl.offBuf.resizeCanvas(e,e)}
function initRandomSeed(e){CHASH=e,resetRnd(CHASH),R20K=new Array(2e4);for(let e=0;e<2e4;e++)R20K[e]=myR01();CNOISEED=myRI(0,32768),noiseSeed(CNOISEED)}
function initStyleSheet(){StSh=null,StSh=new StyleSheet,bBlankCell&&(SHMA=109)}
function initAllPhysics(){
myPs=[];mySs=[];
deferredParticleTargetStructures=[];
deferredStructures=[];myFlocks=[];d3Data=[];
nInteriorPoints= N_INIT_INTERIOR_PTS;
myFrmCnt=myMillis=fadeInPhysics=0;
bTemperatureCooling=F;TMP=1;initFreezeT=-1e5;
GrabStrcId=-1;GrabPid=-1;bFirstTimeForMask=T;
generateMask(bFirstTimeForMask);resetRnd(CHASH);
copyParticlesToD3Data(1);copyParticlesToD3Data(2);
d3Delaunay=new d3.Delaunay(d3Data);
d3Voronoi=d3Delaunay.voronoi([0,0,BDM,BDM]);
for(let i=0;i<10;i++){myFlocks[i]=[];}}
//SCHEMA
function tryToInitializeStructures(){try{initStructures();}catch(theError){recoverFromBadHash();}}
function recoverFromBadHash(){
nRetries++;if(StSh.bDoStamp){stampTB4Bad=T;}
print("Generating revision #"+nRetries);
let H=CHASH;CHASH=incrementHashCharAt(CHASH,curFolio),folioHs[curFolio]==H&&(folioHs[curFolio]=CHASH),resetRnd(CHASH),makeCell(CHASH);
StSh.bDoStamp=myABFeatures.Indica=stampTB4Bad;
}
function incrementHashCharAt(t,n){n=2+n%(t.length-2);const r="0123456789abcdef";let e=r.indexOf(t.charAt(n)),c=r.charAt((e+1)%16);return t.substring(0,n)+c+t.substring(n+1)}
function initStructures(){switch(wheelStylePairs=[[[0,2],8],[[0,4],9],[[0,6],2],[[0,8],6],[[0,9],1],[[0,10],1],[[0,11],1],[[0,12],2],[[1,0],1],[[1,2],5],[[1,3],4],[[1,4],3],[[1,6],1],[[1,7],1],[[1,8],2],[[1,9],3],[[1,11],4],[[1,12],1],[[1,14],2],[[2,0],3],[[2,1],2],[[2,3],2],[[2,4],2],[[2,5],1],[[2,6],1],[[2,7],4],[[2,8],3],[[2,9],8],[[2,10],2],[[2,11],1],[[2,12],3],[[2,14],1],[[3,2],5],[[3,4],8],[[3,6],2],[[3,7],4],[[3,8],3],[[3,11],2],[[3,12],3],[[3,14],2],[[4,0],5],[[4,2],4],[[4,3],2],[[4,5],4],[[4,6],7],[[4,7],9],[[4,9],7],[[4,10],2],[[4,12],1],[[4,17],1],[[5,6],1],[[5,7],3],[[5,8],1],[[5,17],3],[[6,0],1],[[6,3],3],[[6,4],8],[[6,5],7],[[6,8],2],[[6,9],2],[[6,12],1],[[7,2],2],[[7,3],2],[[7,4],6],[[7,6],2],[[7,8],2],[[7,12],2],[[8,0],2],[[8,1],1],[[8,2],7],[[8,3],2],[[8,5],2],[[8,6],5],[[8,7],2],[[8,9],4],[[8,10],1],[[8,11],5],[[8,12],1],[[8,14],3],[[8,17],1],[[17,0],1],[[17,1],1],[[17,2],1],[[17,3],1],[[17,5],4],[[17,6],1],[[17,7],1],[[17,8],1],[[17,10],1],[[17,12],1]],loopStylePairs=[[[0,0],20],[[0,2],15],[[2,5],20],[[0,5],20],[[2,4],23],[[3,3],2]],resetRnd(CHASH),addStrc(ST10,0,0),StSh.bDoRings&&addStrc(ST11,0,0),SHMA){
case 207:StSh.bDrawVs=F,StSh.bDrawBs=R20K[5]<.8,StSh.siteBlbFCol=255,StSh.siteBlbSCol=0,StSh.wheelMassMultiplier=5;let e={style:getWop([[0,10],[1,20],[3,35],[6,35]]),initSz:1,tgtSz:1},t=niceSiteIds.length>6?F:T,S={style:getWop([[0,5],[5,25],[9,25],[10,10],[11,10],[12,10],[13,15]]),initSz:9,tgtSz:9},l=mySs.length,r=F,o=0;for(let e=0;e<niceSiteIds.length;e++){let t=niceSiteIds[e],S=sitePs[t].p;if(t<nSpineSites){getDT(F,-1);let e=getDTAtLoc(S.x,S.y),d=int(map(e,100,400,8,26,T)),s=round(map(e,100,400,1,4,T)),i={style:getWop([[0,15],[1,20],[2,35],[3,35]]),spineLen:s,urchinLen:d},a=addStrc(ST7,S.x,S.y,i);a&&(a.siteAttachId=t,l++,o++),d>18&&(r=T),r&&addDeferDecos([mySs.length-1],20,5,-1)}}for(let r=0;r<niceSiteIds.length;r++){let o=niceSiteIds[r],d=sitePs[o].p;if(o>=nSpineSites){if(t){let e=addStrc(ST4,d.x,d.y,S);e&&(e.siteAttachId=o,l++)}let r=addStrc(ST3,d.x,d.y,e);r&&(r.siteAttachId=o,l++)}}let d=myRAB(.5,.85),s=30,i=abs(pArea(resampNoiBlobPolyl.points)),a=int(2+6*pow(myR01(),2)),y=int(d*PI2*sqrt(i/a/PI)/REST_L),p=getWop([[[0,2],10],[[0,5],20],[[0,1],15],[[2,5],15],[[5,2],10],[[2,1],20],[[5,1],10]]),g=int(i/750/a);o<2&&(g=int(1.5*g)),StSh.blobDrpPct=0,0!=p[0]&&2!=p[0]&&5!=p[0]||(StSh.blobDrpPct=getWop([[0,85],[.75,10],[.95,5]]));let n=getWop([[T,30],[F,70]]);for(let e=0;e<a;e++){let t=p[0],S=y,r=g;n&&0==e&&(t=p[1],S=int(y*a*1.5/(a+1.5)),r=int(g/8));let o={style:t,initSz:max(5,int(y/4)),tgtSz:S,bAddDeferredParticleGroup:T,howManyDeferredParticles:r,delayToAddParticles:20};addDeferStr(0,ST1,1,s+20*e,o),l++}if(getWop([[T,20],[F,80]])){let e=100-10*a;e&&addDeferPs(0,e,s+20*a+20)}if(!r&&a>0){let e=l-a;n&&e++;let t=getWop([[5,70],[20,20]])+myRI(0,5);addDeferDecos([e],100,t,ST2)}break;
case 206:{StSh.bProgAddLpsWhls=myR01()<.15,StSh.bGroAtKink=F,StSh.bLoopGrdy=F,StSh.progAddType,ST4,StSh.blbIntExtRatio=1,StSh.siteBlbFCol=255,StSh.bLoopShoEnclBl=T,StSh.blbTgtLenPoke=.9,StSh.maxNProgressivelyAddedBlobs=10,StSh.bDrawVs=getWop([[T,80],[F,20]]),StSh.progAddType=getWop([[ST1,35],[ST4,65]]),StSh.bDrawBs=getWop([[T,80],[F,20]]),StSh.progAddType==ST1&&(StSh.bDrawBs=T),StSh.addStrcFrmDur=int(getSGauss(350,800,1,-.22)),StSh.addStrcFrmCyc=int(getSGauss(5,45,.45,-.2)),StSh.proportionOfParticlesToAddToBlobs=.5,StSh.minOccupancyForProgressivelyAddedBlobs=.5,StSh.minDistInRestLengths=2;let e=getWop([[1,75],[2,25]]),t=abs(pArea(resampNoiBlobPolyl.points)),S=sqrt(t),l=myRAB(.8,.9),r=l*S/e;StSh.progressivelyAddedBlobStylePair=getWop(wheelStylePairs);let o=null;for(let t=0;t<e;t++){let e=getDT(F,-1),t=e.dtx,S=e.dty;if(S>0&&t>0){let e=StSh.progressivelyAddedBlobStylePair[0];o=addStrc(ST4,t,S,{style:e,initSz:5,tgtSz:r})}}if(1==e&&o){let e=o.id;if(o.bShoVorCls||o.bShoVorEdgs?(myR01()<.8&&addDeferPs(o.id,myRI(25,50),60),e=0):o.bShowEnclBl=F,myR01()<.4){let t=myRI(2,5);addDeferStr(e,ST8,1,100,{style:t,initSz:33})}}let d=getWop([[0,2],[1,3],[2,25],[3,50],[4,20]]);d=min(d,~~(S/100));let s=getWop(loopStylePairs),i=250;for(let e=0;e<d;e++){let t={style:s[0],tgtSz:myRI(30,45),bAddDeferredParticleGroup:T,howManyDeferredParticles:40,delayToAddParticles:60};addDeferStr(0,ST1,1,i+20*e,t)}if(getWop([[T,20],[F,80]])&&S>400){let e=100-10*d+int(100*(1-l));addDeferPs(0,e,i+20*d+20)}}break;