memoscan
← all memos

Memo 0xd1fa3534…1cbe2a on Ethereum

let hash = tokenData.hash class Random { constructor() { this.useA = false; let sfc32 = function (uint128Hex) { let a = parseInt(uint128Hex.substr(0, 8), 16); let b = parseInt(uint128Hex.substr(8, 8), 16); let c = parseInt(uint128Hex.substr(16, 8), 16); let d = parseInt(uint128Hex.substr(24, 8), 16); return function () { a |= 0; b |= 0; c |= 0; d |= 0; let t = (((a + b) | 0) + d) | 0; d = (d + 1) | 0; a = b ^ (b >>> 9); b = (c + (c << 3)) | 0; c = (c << 21) | (c >>> 11); c = (c + t) | 0; return (t >>> 0) / 4294967296; }; }; // seed prngA with first half of tokenData.hash this.prngA = new sfc32(tokenData.hash.substr(2, 32)); // seed prngB with second half of tokenData.hash this.prngB = new sfc32(tokenData.hash.substr(34, 32)); for (let i = 0; i < 1e6; i += 2) { this.prngA(); this.prngB(); } } // random number between 0 (inclusive) and 1 (exclusive) random_dec() { this.useA = !this.useA; return this.useA ? this.prngA() : this.prngB(); } // random number between a (inclusive) and b (exclusive) random_num(a, b) { return a + (b - a) * this.random_dec(); } // random integer between a (inclusive) and b (inclusive) // requires a < b for proper probability distribution random_int(a, b) { return Math.floor(this.random_num(a, b + 1)); } // random boolean with p as percent liklihood of true random_bool(p) { return this.random_dec() < p; } // random value in an array of items random_choice(list) { return list[this.random_int(0, list.length - 1)]; } } let R = new Random() const rseed = Math.floor(R.random_dec()*10000) const nseed = Math.floor(R.random_dec()*10000) console.log(rseed) console.log(nseed) const col_pat = [ ["#001524","#15616d","#ffecd1","#ff7d00","#78290f"], ["#353535","#3c6e71","#ffffff","#d9d9d9","#284b63"], ["#03045e","#0077b6","#00b4d8","#90e0ef","#caf0f8"], ["#264653","#2a9d8f","#e9c46a","#f4a261","#e76f51"], ["#f9dbbd","#ffa5ab","#da627d","#a53860","#450920"], ["#08090a","#a7a2a9","#f4f7f5","#575a5e","#222823"], ["#d6d6d6","#ffee32","#ffd100","#202020","#333533"], ["#540d6e","#ee4266","#ffd23f","#3bceac","#0ead69"], ["#10A19D","#540375","#FF7000","#FFBF00"], ["#041C32","#04293A","#064663","#ECB365"], ["#425F57","#749F82","#A8E890","#CFFF8D"] ] const glitch = R.random_dec()<0.65 const lines = Math.floor(R.random_dec()*3) const frameon = R.random_dec()<0.5 const colorid = Math.floor(R.random_dec()*col_pat.length) const bgcolorid = Math.floor(R.random_dec()*col_pat[colorid].length) function keyPressed(){ if( key == "S" || key == "s" ){ save("save_" + hash + ".png") } } function setup() { let ratio = 4/3 let wind_h = windowHeight let setWidth = wind_h / ratio if(wind_h > setWidth){ createCanvas(setWidth, wind_h) } else{ let setHeight = windowWidth * ratio createCanvas(windowWidth, setHeight) } w = width h = height randomSeed(rseed) noiseSeed(nseed) cols = col_pat[colorid] for(let i=0;i<cols.length*2;i++){ let f0 = int(random(cols.length)) let f1 = int(random(cols.length)) let tmp = cols[f0] cols[f0] = cols[f1] cols[f1] = tmp } img = createGraphics(w, h) img.colorMode(HSB) bg = lerpColor(color(255), color(cols[bgcolorid]), 0.08) let cn = cols.length for(let i=0;i<cn;i++){ img.push() img.stroke(0,0) img.fill(cols[i]+"30") img.rect(0, h/cn*i, w, h/cn) img.pop() } for(let i=0;i<200;i++){ img.strokeWeight(random(1,8)) //s=random(w) img.stroke(random(cols) + "60") img.line(random(-w*0.2,w*1.2), random(-h*0.2,h*1.2), random(-w*0.2,w*1.2), random(-h*0.2,h*1.2)) if(random()<0.4){ if(random()<0.1){ img.fill(random(cols) + "60") } else{ img.fill(0,0) } img.stroke(random(cols) + "60") img.rect(random(w),random(h),random(w*0.35)) } } function pcal(){ return PI*random(-1,1) } //Attractor Parameter a0 = pcal() b0 = pcal() c0 = pcal() d0 = pcal() a1 = pcal() b1 = pcal() c1 = pcal() d1 = pcal() a2 = pcal() b2 = pcal() c2 = pcal() d2 = pcal() //Attractor Parameter oa0 = pcal() ob0 = pcal() oc0 = pcal() od0 = pcal() oa1 = pcal() ob1 = pcal() oc1 = pcal() od1 = pcal() oa2 = pcal() ob2 = pcal() oc2 = pcal() od2 = pcal() //Draw Parameter draw_scale = 5/18*w N = 1800000 ln = 20000 cnt = 0 sn = Math.sin cs = Math.cos x = random(-1,1); y = random(-1,1); background(bg) colorMode(HSB) imageMode(CENTER) cnv = createGraphics(w, h) bgn = back_noise() } function draw(){ if(cnt < N){ cnv.push() cnv.strokeWeight(1/750*w) cnv.translate(w/2, h/2) for(let i=0;i<ln;i++){ let I = int(random(3)); let dx, dy; switch(I){ case 0: dx = sn(a0*y+oa0) + cs(b0*x+ob0) + sn(noise(x*0.07,y*0.08,552)*PI); dy = sn(c0*x+od0) + cs(d0*y+oc0) + cs(noise(x*0.08,y*0.07,252)*PI)*0.5; break; case 1: dx = sn(a1*y+oa1) + cs(b1*x + noise(x*0.05,y*0.05,55)*PI +ob1); dy = sn(c1*x+oc1) + cs(d1*y + noise(x*0.02,y*0.03,22)*PI +od1); break; case 2: dx = sn(a2*y+oa2) + cs(b2*x+ob2) + sn(noise(x*0.04,y*0.09,821)*PI*4)*0.5 dy = sn(c2*x+oc2) + cs(d2*y+od2) + cs(noise(x*0.09,y*0.04,323)*PI*4) break; default: break; } col = img.get(int(draw_scale*x+w/2), int(draw_scale*y+h/2)) col = cnv.color(...col) col.setAlpha(50) cnv.stroke(col) let nsy = cs(noise(x*0.1+b0,y*0.07+b1,873+cnt/N*0.1)*PI)*0.1 cnv.point(draw_scale*dx*(1-cos(cnt/N*TAU*10+a0)*0.02), draw_scale*(dy+nsy)*(4/3-sin(cnt/N*TAU*3+a1)*0.035)) if(random()<0.5){ cnv.stroke(0,27) let xr = dx * cs(dy*PI/2.5) let xt = dx * sn(dy*PI/2.5) cnv.point(draw_scale*xr*0.4, draw_scale*xt*0.4*4/3) } x = dx; y = dy; cnt++ } cnv.pop() background(bg) image(bgn, w/2, h/2) image(cnv, w/2, h/2) if(random()<0.009){ if(lines>0){ flines() } } if(frameon){ framedraw() } } else { if(glitch){ flip() } if(lines>0){ push() fill(0,0) strokeWeight(1/720*w) for(let i=0;i<30;i++){ stroke(random(cols)+"80") if(lines == 1){ line(random(-w*0.2,w*1.2), random(-h*0.2,h*1.2), random(-w*0.2,w*1.2), random(-h*0.2,h*1.2)) } if(lines == 2){ let cp =[] for(let c=0;c<4;c++){ cp.push(random(-w*0.2,w*1.2)) cp.push(random(-h*0.2,h*1.2)) } if(random()<0.5){curve(...cp)} else{bezier(...cp)} } } pop() } if(frameon){ framedraw() } noLoop() } } function framedraw(){ push() rectMode(CENTER) strokeWeight(8/720*w) fill(0,0) stroke(0) rect(w/2,h/2,w,h) pop() } function flines(){ cnv.push() cnv.fill(0,0) cnv.strokeWeight(1/720*w) for(let i=0;i<30;i++){ cnv.stroke(random(cols)+"80") if(lines == 1){ cnv.line(random(-w*0.2,w*1.2), random(-h*0.2,h*1.2), random(-w*0.2,w*1.2), random(-h*0.2,h*1.2)) } if(lines == 2){ let cp =[] for(let c=0;c<4;c++){ cp.push(random(-w*0.2,w*1.2)) cp.push(random(-h*0.2,h*1.2)) } if(random()<0.5){cnv.curve(...cp)} else{cnv.bezier(...cp)} } } cnv.pop() } function back_noise(){ let bri = brightness(bg) let al = bri*0.9 let ls=800 let noiseGra = createGraphics(ls, ls*4/3) let wn = w/720 let hn = h/720 noiseGra.loadPixels() for(let x=0;x<ls;x+=1){ for(let y=0;y<ls*4/3;y+=1){ let ii = x*wn + 150; let jj = y*hn + 80; let nx = noise(ii*0.1,jj*jj*0.05); let fx = (nx>0.7) ? 0.8 : (nx>0.4) ? 0.5 : 0.0; noiseGra.set(x, y, color(al, fx*0.5)) } } noiseGra.updatePixels() let img = createGraphics(w, h) img.colorMode(HSB) img.push() img.tint(100,0.2) img.image(noiseGra, 0, 0, w, h) img.pop() noiseGra = createGraphics(ls, ls*4/3) noiseGra.loadPixels() for(let x=0;x<ls;x+=1){ for(let y=0;y<ls*4/3;y+=1){ let ii = x*wn + 80; let jj = y*hn + 150; let ny = noise(ii*ii*0.5,jj*0.1); let fy = (ny>0.7) ? 0.8 : (ny>0.4) ? 0.5 : 0.0; noiseGra.set(x, y, color(al, fy*0.5)) } } noiseGra.updatePixels() img.push() img.tint(100,0.2) img.image(noiseGra, 0, 0, w, h) img.pop() return img } function flip(){ let N = 10 let wn = w/N let hn = h/N for(let l=0;l<2;l++){ for(let i=0;i<=N;i++){ for(let j=0;j<=N;j++){ if(random()<0.35){ push() let xs=random([1,2,3]) let ys=random([1,2,3]) let ii=int(random(N)) let jj=int(random(N)) translate(wn*(ii+0.5), hn*(jj+0.5)); rotate(random([0, PI/2, PI, PI/2*3])); tint(150,0.17) image(cnv, 0, 0, wn*xs, hn*ys, wn*i, hn*j, wn*xs, hn*ys) pop() } } } } }