Skip to content

Instantly share code, notes, and snippets.

@diegodorado
Created August 12, 2020 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegodorado/e0e16efd2cee024d95ff7dc1e8b1e141 to your computer and use it in GitHub Desktop.
Save diegodorado/e0e16efd2cee024d95ff7dc1e8b1e141 to your computer and use it in GitHub Desktop.
hydra+p5+webgl
try{p.remove()}catch{}
p = new P5({mode:'WEBGL'}) // start again
d = 10
w =200
d2 = d*d
q = Array.from({length: d2}, () => Math.random())
l = Array.from({length: d}, () => Math.round(Math.random()*d2))
p.draw = () => {
let t = p.millis()/1000
t *=2
p.background(0);
p.fill(0)
p.strokeWeight(4)
p.rotateX(-0.15);
for(let i=0;i<=d;i++){
p.push();
p.translate((i-(d/2))*w, 70 , 0);
for(let j=0;j<=d;j++){
z = (j+3-d+(t+j)%1)
index = (i*10-z+t)%d2
s = q[index]
p.push()
p.translate(0, 0 ,w*z)
p.push()
if(l.includes(index) )
p.stroke(255,0,255)
else
p.stroke(0,255,255)
p.box(w*0.2+(s*w*0.5))
p.sphere(w*0.1+(s*w*0.3))
p.pop()
p.pop()
}
p.pop()
}
}
p.hide()
s0.init({src: p.canvas})
src(s0)
.add(src(o0).scrollY(0.5), 0.9)
.scale(1.5)
.mult(osc(5, 0.2, 2),0.5)
.hue(0.04)
.out()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment