memoscan
← all memos

Memo 0xe0c98f45…542645 on Ethereum

class Random{constructor(){this.useA=!1;let o=function(o){let e=parseInt(o.substr(0,8),16),t=parseInt(o.substr(8,8),16),r=parseInt(o.substr(16,8),16),i=parseInt(o.substr(24,8),16);return function(){e|=0,t|=0,r|=0,i|=0;let o=(e+t|0)+i|0;return i=i+1|0,e=t^t>>>9,t=r+(r<<3)|0,r=r<<21|r>>>11,r=r+o|0,(o>>>0)/4294967296}};this.prngA=new o(tokenData.hash.substr(2,32)),this.prngB=new o(tokenData.hash.substr(34,32));for(let o=0;o<1e6;o+=2)this.prngA(),this.prngB()}random_dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}random_num(o,e){return o+(e-o)*this.random_dec()}random_int(o,e){return Math.floor(this.random_num(o,e+1))}random_bool(o){return this.random_dec()<o}random_choice(o){return o[this.random_int(0,o.length-1)]}}let R=new Random,particles=[];const numParticles=R.random_num(5e3,1e4),noiseScale=R.random_num(1e-4,.001),webStrength=R.random_num(3,12),noiseStrength=40,agents=[],nAgents=2e3,grid=[],gridSize=100,decayRate=.001,sensorAngle=Math.PI/4,sensorDistance=80,rotationAngle=Math.PI/8,stepSize=.9,seed=8000950490343*R.random_num(0,1);let pd,audioContext,gainNode,masterGainNode,melody;a=R.random_num(1,200),b=R.random_num(400,1e3);let bgColor,c1,c2,c3,c4,c5,noteIndex=0,noteStartTime=10,framerate=60,framesPerNote=10,audioStarted=!1,choiceColor=R.random_int(0,9);function setup(){createCanvas(windowWidth,windowHeight),noiseSeed(seed),setPg(),pg.pixelDensity(2),bgColor=[color("black"),color("grey"),color("white"),color("rgb(81,117,47)"),color("rgb(0,0,110)"),color("rgb(4,2,95)"),color("black"),color("rgb(252,190,144)"),color("rgb(182,3,3)"),color("rgb(182,178,150)")],pg.background(bgColor[choiceColor]),pg.frameRate(framerate);for(let o=0;o<numParticles;o++)particles[o]=new Particle(R.random_num(0,pg.width),R.random_num(0,pg.height));for(let o=0;o<2e3;o++)agents.push(new Agent);for(let o=0;o<gridSize;o++){const o=[];for(let e=0;e<gridSize;e++)o.push(0);grid.push(o)}audioContext=new(window.AudioContext||window.webkitAudioContext),masterGainNode=audioContext.createGain(),masterGainNode.connect(audioContext.destination),masterGainNode.gain.setValueAtTime(.1,audioContext.currentTime)}function draw(){frameCount>300&&noLoop();for(const o of agents)o.update(),o.display();for(let o of particles)o.update(),o.display();decayGrid(),drawPg()}function mouseClicked(){startAudio(),playDrum(),playNote()}function touchStarted(){return startAudio(),playDrum(),playNote(),!1}function startAudio(){audioStarted||(audioContext.resume(),audioStarted=!0)}console.log(choiceColor),audioStarted&&frameCount%framesPerNote==0&&(playNote(),playDrum());class Particle{constructor(o,e){this.pos=pg.createVector(o,e),this.prevPos=this.pos.copy()}update(){this.prevPos=this.pos.copy();let o=noise(this.pos.x*noiseScale,this.pos.y*noiseScale),e=map(o,0,1,0,TWO_PI+frameCount/2),t=p5.Vector.fromAngle(e);t.mult(40),this.pos.add(t),this.pos.x=(this.pos.x+pg.width)%pg.width,this.pos.y=(this.pos.y+pg.height)%pg.height}display(){c1=[color(255,255,255,50),color(255,255,255,50),color(255,40,20,50),color(255,255,255,50),color(255,255,255,50),color("rgb(252,250,250, 50)"),"rgb(92,226,4)",color("yellow"),"yellow",color("rgb(255,255,255, 50)")],c2=[color(255,40,20,50),color("black"),color("black"),color("black"),color("orange"),color("rgb(38,145,255)"),color("yellow"),color("rgb(3,3,3)"),color("black"),color("rgb(2,2,2)")],c3=[color(255,255,255,50),color("rgb(255,140,0)"),color(255,255,255,50),color("black"),color(255,255,255,50),color("rgb(3,57,226)"),color("255, 255, 255, 50"),color("255, 255, 255, 50"),color("blue"),color("255, 255, 255, 50")],c4=[color(255,40,20,50),color(255,255,255,50),color(255,40,20,50),color("black"),color("orange"),color("rgb(0,147,255)"),color("yellow"),color("rgb(5,5,5)"),color("255, 255, 255, 50"),color("rgb(253,253,253, 50)")],c5=[color(25,25,25,50),color(25,25,25,50),color(255,255,255,50),color(255,255,255,50),color(255,255,255,50),color("rgb(243,242,242)"),color("white"),color("yellow"),"yellow",color("rgb(252,250,250, 50)")],pg.stroke(c1[choiceColor]),frameCount>50&&pg.stroke(c2[choiceColor]),frameCount>100&&pg.stroke(c3[choiceColor]),frameCount>150&&pg.stroke(c4[choiceColor]),frameCount>200&&pg.stroke(c5[choiceColor]),pg.strokeWeight(.5),pg.point(this.prevPos.x,this.prevPos.y)}}class Agent{constructor(){this.pos=pg.createVector(R.random_num(0,pg.width),R.random_num(0,pg.height)),this.angle=R.random_num(0,TWO_PI)}update(){const o=floor(this.pos.x/(pg.width/gridSize)),e=floor(this.pos.y/(pg.height/gridSize)),t=p5.Vector.fromAngle(this.angle-sensorAngle,80).add(this.pos),r=p5.Vector.fromAngle(this.angle+sensorAngle,80).add(this.pos),i=(floor(t.x/(pg.width/gridSize))+gridSize)%gridSize,n=(floor(t.y/(pg.height/gridSize))+gridSize)%gridSize,a=(floor(r.x/(pg.width/gridSize))+gridSize)%gridSize,s=(floor(r.y/(pg.height/gridSize))+gridSize)%gridSize;grid[n][i]>grid[s][a]?this.angle-=rotationAngle:this.angle+=rotationAngle;const l=p5.Vector.fromAngle(this.angle,.9);this.pos.add(l),this.pos.x=(this.pos.x+pg.width)%pg.width,this.pos.y=(this.pos.y+pg.height)%pg.height,grid[e][o]=min(grid[e][o]+.1,1)}display(){const o=floor(this.pos.x/(pg.width/gridSize)),e=floor(this.pos.y/(pg.height/gridSize)),t=grid[e][o],r=map(t,0,1,0,200);pg.stroke(r,webStrength),pg.strokeWeight(.1);const i=p5.Vector.fromAngle(this.angle-sensorAngle,80).add(this.pos);p5.Vector.fromAngle(this.angle+sensorAngle,80).add(this.pos);pg.line(this.pos.x,this.pos.y,i.x,i.y),pg.stroke(r,r,r,webStrength),pg.strokeWeight(.9),pg.point(this.pos.x,this.pos.y)}}function decayGrid(){for(let o=0;o<gridSize;o++)for(let e=0;e<gridSize;e++)grid[o][e]*=1-decayRate}function playNote(){const o=audioContext.createOscillator();o.type="sine",gainNode=audioContext.createGain(),o.connect(gainNode),gainNode.connect(masterGainNode);const e=R.random_num(a,b);o.frequency.setValueAtTime(e,audioContext.currentTime),o.start();const t=.01,r=audioContext.currentTime;gainNode.gain.setValueAtTime(0,r),gainNode.gain.linearRampToValueAtTime(1,r+t),gainNode.gain.linearRampToValueAtTime(.21,r+t+.5),gainNode.gain.linearRampToValueAtTime(0,r+t+.5+10.1),o.stop(r+t+.5+10.1)}function playDrum(){const o=audioContext.createOscillator();o.type="noise";const e=audioContext.createBiquadFilter();e.type="lowpass",e.frequency.value=1e3,e.Q.value=1,gainNode=audioContext.createGain(),o.connect(e),e.connect(gainNode),gainNode.connect(masterGainNode);const t=R.random_num(a/2,b/2);o.frequency.setValueAtTime(t,audioContext.currentTime),o.start();const r=.001,i=12.1,n=audioContext.currentTime;gainNode.gain.setValueAtTime(0,n),gainNode.gain.linearRampToValueAtTime(1,n+r),gainNode.gain.exponentialRampToValueAtTime(.1,n+r+i),gainNode.gain.exponentialRampToValueAtTime(.01,n+r+i+1.5),o.stop(n+r+i+1.5)}function setPg(){let o;ar=getAspectRatio(),print("Aspect Ratio: "+(1==ar?"1:1":2==ar?"16:9":"ISO_216")),1==ar?o=createVector(946*2.3,793*2.3):2==ar?o=createVector(1280,720):3==ar&&(o=createVector(9933/9,14043/9)),pg=createGraphics(o.x,o.y),pd=PixelDensity(),pg.pixelDensity(pd),print("Pixel Density: "+pd),print("Final resolution: "+round(o.x*pd)+"x"+round(o.y*pd)+"pixels")}function generateFileName(){return"vendaval.png"}function keyPressed(){"s"==key&&(fileName=generateFileName(),print("Saving image... "+fileName),print("Final resolution: "+round(pg.width*pd)+"x"+round(pg.height*pd)+"pixels"),save(pg,fileName)),"1"==key?(window.location.hash=ar+"1",location.reload()):"2"==key?(window.location.hash=ar+"2",location.reload()):"3"==key?(window.location.hash=ar+"3",location.reload()):"4"==key?(window.location.hash=ar+"4",location.reload()):"5"==key?(window.location.hash=ar+"5",location.reload()):"6"==key?(window.location.hash=ar+"6",location.reload()):"7"==key?(window.location.hash=ar+"7",location.reload()):"8"==key?(window.location.hash=ar+"8",location.reload()):"9"==key&&(window.location.hash=ar+"9",location.reload())}function saveFrame(){save(buffer,generateFileName())}function PixelDensity(){let o=window.location.hash.split("");switch(o=o[o.length-1],o){case"1":return 21;case"2":return 2;case"3":return 3;case"4":return 4;case"5":return 5;case"6":return 6;case"7":return 7;case"8":return 8;case"9":return 9;default:return pixelDensity()}}function getAspectRatio(){let o=window.location.hash.split("");switch(o=o[o.length-2],o){case"1":default:return 1;case"2":return 2;case"3":return 3}}function drawPg(){imageMode(CENTER),width>=height?image(pg,width/2,height/2,pg.width*height/pg.height,height):image(pg,width/2,height/2,width,pg.height*width/pg.width)}