escent Pearl"],[168,165,146,"Iridescent Silver"],[144,142,127,"Iridescent German Silver"],[80,86,84,"Iridescent Pewter"],[67,73,71,"Graphite Grey"],[36,42,40,"Lamp Black"],[229,211,175,"Unbleached Titanium"],[181,191,180,"Cerulean Grey"],[193,198,191,"Neutral Grey Pale"],[146,163,170,"Neutral Grey Light"],[120,137,145,"Neutral Grey Medium"],[86,104,118,"Neutral Grey Deep"],[104,107,88,"Turkey Umber Pale"],[39,43,42,"Mars Black"],[44,50,50,"Ivory Black"],[27,31,30,"Intense Carbon Black"],[233,227,205,"Neutral White"],[253,252,247,"Titanium-Zinc White"]];const e=[[24,25,26,98,99,100,101,55,48,34,35,22,1,2],[23,101,24,84,63,48,83,3,21,39,73,88,97,69,46,37,2,9,25,16,10,33,52,41],[97,98,92,54,25,44,47,28,24,12,99],[10,24,53,84,16,56,97,5,1,61,99,21,98,33,43,63,58,86,25],[60,64,69,3,4,101,2,21,12,88,50,8,59,95,44,69,95,76],[39,52,12,24,3,16,28,49,2,101,44,33,33,69,77,7,43,28],[88,89,97,98,99,100,101,90,91,92,93,94,95,86,85,84,69,58,59,63],[48,98,85,2,38,9,100,3,5,14,90,99,97],[100,62,49,25,24,47,36,23,56,12,84,38,13,99,52,53],[25,15,26,19,17,16,6,5,84,101,100,92,94,95,88,99,98,69,46,35,48,36,37,58,55],[89,26,41,62,15,2,61,39,3,22,45,51,56,4,44],[100,21,91,10,1,25,2,62,15,81,74,8,18,29,60,53,38,39,56,47,12,55],[89,4,23,72,58,101,15,100,6,38,52,33,99],[12,101,10,4,60,82,68,56,50,58,72,93,35,21,83,34,52,53,91,22,89,1,34,25],[24,2,21,93,10,91,61,87,49,53,46,56,36,58,47,99,81,15,57,9,26,54,94,12]];paletteNames=["Eros","Gaia","Thoth","Ra","Varuna","Ishtar","Nyx","Anubis","Neptune","Enyo","Ceres","Helios","Vulcan","Elysia","Vesta"],selectedPalette=R.random_int(0,e.length-1),convertIndexToPalette(e[selectedPalette]),border=0;let a=getURLParams(),d=void 0!==a.highres&&Number(a.highres);console.log("Apophenies by Cory Haber"),paintCanvasW=3456,paintCanvasH=4608,browserRatio=WIDTH/HEIGHT,dflW=675,dflH=900,bufferRatio=paintCanvasW/paintCanvasH,browserRatio>bufferRatio?(M=HEIGHT/paintCanvasH,canvasW=HEIGHT/paintCanvasH*paintCanvasW,canvasH=HEIGHT):(M=WIDTH/paintCanvasW,canvasW=WIDTH,canvasH=WIDTH/paintCanvasW*paintCanvasH),M*=paintCanvasH/dflH;paintRadius=8,circleCounter=0;drawSteps=20,strokeLength=1.55,maxPerStep=35;let c=R.random_choice([1,2]),f=R.random_int(4,8);opacity=245,opactiyStreak=230,maxStreakLen=6;let t=R.random_choice([150,350,550,650,750,1e3]),r=[130,170,210,250,300,350],n=R.random_int(0,r.length-1),b=R.random_choice([-2,-1,0,1,2]),o=r[n],l=r[b+n<0?0:b+n>r.length-1?r.length-1:b+n],i=R.random_choice([100,150,200,250,300,400]),s=R.random_choice([150,200,230,250]),u=6+(o+l-300)/400*4;resolution=2,nameIndex=0;paletteNames[selectedPalette];pd=!1===d?pixelDensity():d,pixelDensity(pd),pdb=1,gridArr=new Float32Array(dflH*pdb*(dflW*pdb)),createCanvas(canvasW,canvasH),buffer=createGraphics(dflW,dflH),buffer.pixelDensity(pdb),primaryBuffer(t,o,l,i,s),gridPoints(10.2,f),scharr(gridArr),gaussBlur_4(scharrX,blurX,dflW,dflH,u),gaussBlur_4(scharrY,blurY,dflW,dflH,u),gridOfAngles(blurX,blurY,grid,resolution),precalculatePalette(),preprocessStrokes(strokes,buffer,c),colorNames=Array.from(colorsUsed);usedPaletteColors.filter(((e,a,d)=>a===d.findIndex((a=>JSON.stringify(a)===JSON.stringify(e)))));colorSort(1),sortedNames=sortedColorName(),background(229,211,175,255),drawStrokes()}function primaryBuffer(e,a,d,c,f){let t,r,n,b,o,l,i,s,u,p,x,h,m,g,k,y;palette.sort(((e,a)=>luminance(a)-luminance(e))),buffer.background(255),buffer.noStroke();for(let h=0;h<e;h++)t=R.random_int(0,dflW),r=R.random_int(0,dflH),n=R.random_int(10,a),b=R.random_int(10,d),o=R.random_int(0,c),l=R.random_int(0,palette.length-1),i=palette[l][0],s=palette[l][1],u=palette[l][2],p=t-n/2,x=r-b/2,buffer.fill(i,s,u,f),buffer.rect(p,x,n,b,o),150===f&&buffer.ellipse(t,r,n,b);buffer.loadPixels(),index=0;for(let e=0;e<dflH;e++){let a=e*dflW*pdb*pdb;for(let e=0;e<dflW;e++)h=4*(e*pdb+a),m=buffer.pixels[h],g=buffer.pixels[h+1],k=buffer.pixels[h+2],y=(m+g+k)/3|0,gridArr[index++]=y}}function preprocessStrokes(e,a,d){pointsWithColor.length=e.length;for(let c=0;c<e.length;c++)pointsWithColor[c]=getColor(int(e[c].x),int(e[c].y),a,colorsUsed,d)}function precalculatePalette(){for(let e=0;e<palette.length;e++){let a=palette[e][0],d=palette[e][1],c=palette[e][2];preCalculatedSq[e]=[a*a,d*d,c*c]}}function getColor(e,a,d,c,f){let t=4*(e*pdb+a*dflW*pdb*pdb),r=d.pixels[t],n=d.pixels[t+1],b=d.pixels[t+2],o=[];for(let e=0;e<palette.length;e++){let a=sq(palette[e][0]-r)+sq(palette[e][1]-n)+sq(palette[e][2]-b);o.push({dist:a,color:palette[e]})}o.sort(((e,a)=>e.dist-a.dist));let l=R.random_int(0,f),i=o[l].color,s=i[0],u=i[1],p=i[2],x=i[3],h=s+u+p;return c.add(x),colorsScore.add([x,h]),usedPaletteColors.push([s,u,p,x]),[e,a,s,u,p,x,l,h]}function gridPoints(e,a){for(let d=0;d<=dflH;d+=e)for(let c=0;c<=dflW;c+=e){let e=c+R.random_num(-a,a),f=d+R.random_num(-a,a),t=createVector(e,f);append(strokes,t)}}function gridOfAngles(e,a,d,c){let f;for(let t=0;t<dflH;t+=c)for(let r=0;r<dflW;r+=c){let n=r+t*dflW,b=r/c+t/c*(dflW/c),o=e[n],l=a[n];f=degrees(atan2(l,o))+90;let i=radians(f);d[b]=i}}function smoothAngles(){for(let e=1;e<grid.length-1;e++){let a=(grid[e-1]+grid[e]+grid[e+1])/3;avgGrid.push(a)}}async function drawStrokes(){if(nameIndex<sortedNames.length){const e=[0,30,60,90,120,150,180,210,240,270,300,330];let a=[];for(let d=0;d<pointsWithColor.length;d++){let c,f,t=pointsWithColor[d],r=color(t[2],t[3],t[4],opacity);if(noStroke(),t[5]===sortedNames[nameIndex]){for(let d=0;d<drawSteps;d++){let d=int(t[0]),n=int(t[1]),b=int(t[0]/resolution),o=int(t[1]/resolution);if(d>border&&d<dflW-border&&n>border&&n<dflH-border){let l=grid[b+o*(dflW/resolution)];c=strokeLength*cos(l),f=strokeLength*sin(l),t[0]+=c,t[1]+=f;let i=l<0?TWO_PI+l:l;i=degrees(i);let s=e.reduce(((e,a)=>abs(a-i)<abs(e-i)?a:e));noStroke();let u,p,x,h,m,g,k=R.random_int(5,maxPerStep);for(let e=0;e<k;e++)u=R.random_num(0,paintRadius),p=radians(R.random_int(0,360)),x=d+u*cos(p),h=n+u*sin(p),m=R.random_int(1,20),a.push([d*M,n*M]),m<=16?(fill(r),g=R.random_num(.1,1),ellipse(x*M,h*M,g*M,g*M)):paintParticles(x*M,h*M,maxStreakLen,r,s,opactiyStreak),circleCounter++}}beginShape();for(let e=0;e<a.length;e++)noFill(),r.setAlpha(100),stroke(r),strokeWeight(7*M),curveVertex(a[e][0],a[e][1]);a=[],endShape()}}nameIndex++,requestAnimationFrame(drawStrokes)}}function paintParticles(e,a,d,c,f,t){let r=R.random_num(-.01,-.14),n=int(red(c)),b=int(green(c)),o=int(blue(c)),[l,i,s]=adjustLightness(n,b,o,r);fill(l,i,s,t),push(),translate(e,a);let u=R.random_num(.5,1),p=R.random_num(1,d);noStroke(),beginShape();for(let e=0;e<360;e+=30){let a,d,c,t;c=u+R.random_num(-.5,.5),t=radians(e),e===f?(a=(p+c)*cos(t),d=(p+c)*sin(t)):(a=c*cos(t),d=c*sin(t)),curveVertex(a*M,d*M)}endShape(CLOSE),pop()}function colorSort(e){0===e?pointsWithColor.sort(((e,a)=>colorNames.indexOf(e[5])-colorNames.indexOf(a[5]))):1===e?pointsWithColor.sort(((e,a)=>e[7]-a[7])):pointsWithColor.sort(((e,a)=>a[7]-e[7]))}function sortedColorName(){let e=new Set;for(let a=0;a<pointsWithColor.length;a++){let d=pointsWithColor[a][5];e.add(d)}return Array.from(e)}function luminance(e){let[a,d,c]=e;return.299*a+.587*d+.114*c}function genTokenData(e){let a={},d="0x";for(var c=0;c<64;c++)d+=Math.floor(16*Math.random()).toString(16);return a.hash=d,a.tokenId=(1e6*e+Math.floor(1e3*Math.random())).toString(),a}class Random{constructor(){this.useA=!1;let e=function(e){let a=parseInt(e.substr(0,8),16),d=parseInt(e.substr(8,8),16),c=parseInt(e.substr(16,8),16),f=parseInt(e.substr(24,8),16);return function(){a|=0,d|=0,c|=0,f|=0;let e=(a+d|0)+f|0;return f=f+1|0,a=d^d>>>9,d=c+(c<<3)|0,c=c<<21|c>>>11,c=c+e|0,(e>>>0)/4294967296}};this.prngA=new e(tokenData.hash.substr(2,32)),this.prngB=new e(tokenData.hash.substr(34,32));for(let e=0;e<1e6;e+=2)this.prngA(),this.prngB()}random_dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}random_num(e,a){return e+(a-e)*this.random_dec()}random_int(e,a){return Math.floor(this.random_num(e,a+1))}random_bool(e){return this.random_dec()<e}random_choice(e){return e[this.random_int(0,e.length-1)]}}function gaussBlur_4(e,a,d,c,f){var t=boxesForGauss(f,3);boxBlur_4(e,a,d,c,(t[0]-1)/2),boxBlur_4(a,e,d,c,(t[1]-1)/2),boxBlur_4(e,a,d,c,(t[2]-1)/2)}function boxBlur_4(e,a,d,c,f){for(var t=0;t<e.length;t++)a[t]=e[t];boxBlurH_4(a,e,d,c,f),boxBlurT_4(e,a,d,c,f)}function boxBlurH_4(e,a,d,c,f){for(var t=1/(f+f+1),r=0;r<c;r++){for(var n=r*d,b=n,o=n+f,l=e[n],i=e[n+d-1],s=(f+1)*l,u=0;u<f;u++)s+=e[n+u];for(u=0;u<=f;u++)s+=e[o++]-l,a[n++]=Math.round(s*t);for(u=f+1;u<d-f;u++)s+=e[o++]-e[b++],a[n++]=Math.round(s*t);for(u=d-f;u<d;u++)s+=i-e[b++],a[n++]=Math.round(s*t)}}function boxBlurT_4(e,a,d,c,f){for(var t=1/(f+f+1),r=0;r<d;r++){for(var n=r,b=n,o=n+f*d,l=e[n],i=e[n+d*(c-1)],s=(f+1)*l,u=0;u<f;u++)s+=e[n+u*d];for(u=0;u<=f;u++)s+=e[o]-l,a[n]=Math.round(s*t),o+=d,n+=d;for(u=f+1;u<c-f;u++)s+=e[o]-e[b],a[n]=Math.round(s*t),b+=d,o+=d,n+=d;for(u=c-f;u<c;u++)s+=i-e[b],a[n]=Math.round(s*t),b+=d,n+=d}}function boxesForGauss(e,a){var d=Math.sqrt(12*e*e/a+1),c=Math.floor(d);c%2==0&&c--;for(var f=c+2,t=(12*e*e-a*c*c-4*a*c-3*a)/(-4*c-4),r=Math.round(t),n=[],b=0;b<a;b++)n.push(b<r?c:f);return n}function scharr(e){scharrX=new Float32Array(dflW*dflH),scharrY=new Float32Array(dflW*dflH);let a=dflW;for(let d=1;d<dflH-1;d++)for(let c=1;c<dflW-1;c++){let f=c-1+a*(d-1),t=c+a*(d-1),r=c+1+a*(d-1),n=c-1+a*d,b=c+a*d,o=c+1+a*d,l=c-1+a*(d+1),i=c+a*(d+1),s=c+1+a*(d+1),u=e[f]*kx[0][0]+e[t]*kx[0][1]+e[r]*kx[0][2]+e[n]*kx[1][0]+e[b]*kx[1][1]+e[o]*kx[1][2]+e[l]*kx[2][0]+e[i]*kx[2][1]+e[s]*kx[2][2],p=e[f]*ky[0][0]+e[t]*ky[0][1]+e[r]*ky[0][2]+e[n]*ky[1][0]+e[b]*ky[1][1]+e[o]*ky[1][2]+e[l]*ky[2][0]+e[i]*ky[2][1]+e[s]*ky[2][2];scharrX[d*dflW+c]=u,scharrY[d*dflW+c]=p}}function convertIndexToPalette(e){for(let a=0;a<e.length;a++){let d=paletteSet[e[a]];palette.push(d)}}function delayTime(e){return new Promise((a=>setTimeout(a,e)))}function keyPressed(){83===keyCode&&saveOutput(),49===keyCode&&displayOption(1),50===keyCode&&displayOption(2),51===keyCode&&displayOption(3),52===keyCode&&displayOption(4)}function saveOutput(){delayTime(300).then((()=>save("Apophenies #"+invocation+".jpg")))}function reloadDisplay(){delayTime(500).then((()=>location.reload()))}function rgbToHsl(e,a,d){e/=255,a/=255,d/=255;let c,f,t=Math.max(e,a,d),r=Math.min(e,a,d),n=(t+r)/2;if(t==r)c=f=0;els
↓ show full (10,240 bytes)