memoscan
← all memos

Memo 0x39962d03…ec1e5d on Ethereum

var seed=parseInt(tokenData.hash.slice(0,16),16);const PW=1e3,PH=1e3,PD=1414.2136,NUM_TYPES=4,MAX_LIGHTS=7,V2A=0,V2B=1,V3A=2,V3B=3;let _zoom,_num_lines,_max_speed,_num_lights,_linear_sensors,_nerves,_facade,_breadth,lights=new Array(MAX_LIGHTS),machines=[],pause=!1,bangTime=0,showLights=!1,white=[255,255,255],gray=[102,102,102],midgray=[127,127,127],black=[0,0,0],green1=[153,204,0],green2=[166,203,43],blue1=[61,168,201],blue2=[68,182,198],orange=[221,131,99],pink=[224,99,148],warmgray=[153,153,118],coolgray=[118,153,153],cs1=[white,green1,gray,green2,warmgray],cs2=[white,green1,pink,green2,gray],cs3=[white,blue1,gray,blue2,coolgray],cs4=[white,blue1,pink,blue2,gray],cs5=[white,blue1,orange,blue2,gray],cs6=[black,white,white,white,white],cs7=[midgray,white,white,white,white],csx=cs1;function setup(){createCanvas(window.innerWidth,window.innerHeight),pixelDensity(),colorMode(RGB,1),bang()}function draw(){translate(width/2,height/2);let s=max(width,height);scale(s/PW*_zoom);for(let s=0;s<machines.length;s++)machines[s].idle();for(let s=0;s<machines.length;s++)machines[s].display();if(showLights)for(let s=0;s<_num_lights;s++)lights[s].display();1e3===++bangTime&&(pause=!0,noLoop())}function bang(){r=new RND(seed),bangTime=0,pause=!1,showLights=!1,createWorld(),tuneMachines(),createFacade(),createMachines()}function createWorld(){let s=r.rb(0,1);_zoom=s>.9?.66:s>.8?2:1;for(let s=0;s<MAX_LIGHTS;s++)lights[s]=new L(r.rb(-PW/2,PW/2),r.rb(-PH/2,PH/2),10);_num_lights=2+int(r.rb(0,MAX_LIGHTS-1)),print(_num_lights);let e=r.rb(0,1);_num_lines=e>.9?50:e>.85?800:e>.75?200:400}function tuneMachines(){let s=r.rb(0,1);_breadth=s>.8?35:50;let e=r.rb(0,1);_nerves=e>.9?10:e>.8?5:0;let t=r.rb(0,1);_linear_sensors=t>.9;let i=r.rb(0,1);_max_speed=i>.8?4:i>.5?8:12}function createFacade(){let s=r.rb(0,1);csx=s>.9?cs7:s>.6?cs6:s>.5?cs5:s>.4?cs4:s>.3?cs3:s>.15?cs2:cs1,createBackground()}function createBackground(){bg=color(csx[0][0]/255,csx[0][1]/255,csx[0][2]/255),background(bg),strokeCap(SQUARE)}function createMachines(){let s=.5;_nerves<1&&(_num_lines>500?s=.25:_num_lines>300&&(s=.375)),machines=new Array(_num_lines);for(let e=0;e<machines.length;e++){let t=e%NUM_TYPES;machines[e]=new M(r.rb(-PW/2,PW/2),r.rb(-PH/2,PH/2),t,csx[t+1][0]/255,csx[t+1][1]/255,csx[t+1][2]/255,s)}}function keyTyped(){return"p"===key||"P"===key?(pause?loop():noLoop(),pause=!pause):"b"===key||"B"===key?(bang(),loop(),print("bang")):"1"===key?(bang(),loop(),_zoom=.66):"2"===key?(bang(),loop(),_zoom=1):"3"===key?(bang(),loop(),_zoom=2):"4"===key?(bang(),loop(),_zoom=4):"5"===key?(bang(),loop(),_zoom=8):"l"!=key&&"L"!=key||(showLights=!showLights,pause&&redraw()),!1}class L{constructor(s,e,t){this.x=s,this.y=e,this.r=t}display(){fill(1,.7,0),noStroke(),ellipse(this.x,this.y,this.r,this.r)}}class M{constructor(s,e,t,i,h,o,n){this.line_x=this.p_x=s,this.line_y=this.p_y=e,this.species=t,this.ocolor=new Array(3),this.dcolor=new Array(3),this.dcolorNew=new Array(3),this.ocolor[0]=this.dcolor[0]=this.dcolorNew[0]=i,this.ocolor[1]=this.dcolor[1]=this.dcolorNew[1]=h,this.ocolor[2]=this.dcolor[2]=this.dcolorNew[2]=o,this.alpha=n,this.lineRotatenew=0,this.lineRotate=0,this.fade=1,this.death=!1,this.turn_speed=8,this.speed=0,this.expanse=r.rb(0,45)+5,this.line_rotate=r.rb(0,360)}hump(s){return s=1-(s=2*(s-.5))*s}idle(){this.lineRotatenew=radians(this.line_rotate);for(let s=0;s<_num_lights;s++)this.light_x=lights[s].x,this.light_y=lights[s].y,this.lsox=cos(this.lineRotatenew+PI/5)*_breadth,this.lsoy=sin(this.lineRotatenew+PI/5)*_breadth,this.left_sensor_x=this.line_x+this.lsox,this.left_sensor_y=this.line_y+this.lsoy,this.rsox=cos(this.lineRotatenew-PI/5)*_breadth,this.rsoy=sin(this.lineRotatenew-PI/5)*_breadth,this.right_sensor_x=this.line_x+this.rsox,this.right_sensor_y=this.line_y+this.rsoy,this.ldx=this.light_x-this.left_sensor_x,this.ldy=this.light_y-this.left_sensor_y,this.ld=sqrt(this.ldx*this.ldx+this.ldy*this.ldy),this.rdx=this.light_x-this.right_sensor_x,this.rdy=this.light_y-this.right_sensor_y,this.rd=sqrt(this.rdx*this.rdx+this.rdy*this.rdy),this.norm_sensor_left=this.ld/PD,this.norm_sensor_right=this.rd/PD,0==_linear_sensors&&(this.norm_sensor_right=this.hump(this.norm_sensor_right),this.norm_sensor_left=this.hump(this.norm_sensor_left)),this.norm_sensor_average=(this.norm_sensor_left+this.norm_sensor_right)/2,this.species==V2A?(this.speed+=_max_speed-_max_speed*this.norm_sensor_average,this.speed/=2+this.expanse/25,this.line_rotate+=this.ld/this.turn_speed*(1-this.norm_sensor_left),this.line_rotate-=this.rd/this.turn_speed*(1-this.norm_sensor_right)):this.species==V2B?(this.speed+=_max_speed-_max_speed*this.norm_sensor_average,this.speed/=2+this.expanse/25,this.line_rotate+=this.rd/this.turn_speed*(1-this.norm_sensor_right),this.line_rotate-=this.ld/this.turn_speed*(1-this.norm_sensor_left)):this.species==V3A?(this.speed+=_max_speed*this.norm_sensor_average,this.speed/=2+this.expanse/25,this.line_rotate-=this.ld/this.turn_speed*(1-this.norm_sensor_left),this.line_rotate+=this.rd/this.turn_speed*(1-this.norm_sensor_right)):this.species==V3B&&(this.speed+=_max_speed*this.norm_sensor_average,this.speed/=2+this.expanse/25,this.line_rotate-=this.rd/this.turn_speed*(1-this.norm_sensor_right),this.line_rotate+=this.ld/this.turn_speed*(1-this.norm_sensor_left)),this.line_rotate+=r.rb(-_nerves,_nerves);this.dcolorNew[0]=this.ocolor[0]*this.speed*map(_max_speed,4,12,.45,.15),this.dcolorNew[1]=this.ocolor[1]*this.speed*map(_max_speed,4,12,.45,.15),this.dcolorNew[2]=this.ocolor[2]*this.speed*map(_max_speed,4,12,.45,.15),this.dcolorNew[0]=constrain(this.dcolorNew[0],0,this.ocolor[0]),this.dcolorNew[1]=constrain(this.dcolorNew[1],0,this.ocolor[1]),this.dcolorNew[2]=constrain(this.dcolorNew[2],0,this.ocolor[2]),this.speed<.4&&(this.speed=.4),this.dcolor[0]-=(this.dcolor[0]-this.dcolorNew[0])/10,this.dcolor[1]-=(this.dcolor[1]-this.dcolorNew[1])/10,this.dcolor[2]-=(this.dcolor[2]-this.dcolorNew[2])/10,this.lineRotatenew=this.line_rotate/180*PI,this.lineRotatenew<PI/2?(this.yd=sin(this.lineRotatenew)*this.speed,this.xd=cos(this.lineRotatenew)*this.speed,this.line_x+=this.xd,this.line_y+=this.yd):this.lineRotatenew<PI?(this.lineRotatenew-=PI/2,this.yd=cos(this.lineRotatenew)*this.speed,this.xd=sin(this.lineRotatenew)*this.speed,this.line_x-=this.xd,this.line_y+=this.yd):this.lineRotatenew<PI+PI/2?(this.lineRotatenew-=PI,this.yd=sin(this.lineRotatenew)*this.speed,this.xd=cos(this.lineRotatenew)*this.speed,this.line_x-=this.xd,this.line_y-=this.yd):(this.lineRotatenew-=PI+PI/2,this.yd=cos(this.lineRotatenew)*this.speed,this.xd=sin(this.lineRotatenew)*this.speed,this.line_x+=this.xd,this.line_y-=this.yd),this.death&&(this.fade-=.01,fade<0&&(this.fade=1,this.death=!1,this.rebirth()))}kill(){this.death=!0}rebirth(){this.line_x=r.rb(-PW/2,PW/2),this.line_y=r.rb(-PH/2,PH/2),this.p_x=this.line_x,this.p_y=this.line_y}display(){strokeWeight(1),stroke(this.dcolor[0],this.dcolor[1],this.dcolor[2],this.alpha*this.fade),line(this.line_x,this.line_y,this.p_x,this.p_y),this.nextPoint()}nextPoint(){this.p_x=this.line_x,this.p_y=this.line_y}}class RND{constructor(s){this.seed=s}random_dec(){return this.seed^=this.seed<<13,this.seed^=this.seed>>17,this.seed^=this.seed<<5,(this.seed<0?1+~this.seed:this.seed)%1e3/1e3}rb(s,e){return s+(e-s)*this.random_dec()}}