xxxxxxxxxx
40
const n = 2
const sf = [50, 50] // spatial frequencies
const tf = [2, 2] // temporal frequencies
function setup() {
createCanvas(200,500,WEBGL);
body = loadImage("outlineT.png");
t = 0
c = 255
m = 2 * n
noStroke()
}
function draw() {
t += 0.04;
background(255)
// waves
for (let y=0; y<=height; y++) {
c1 = map(sin(y/sf[0]+t*tf[0]),-1,1,-c/m,c/m)
c2 = map(sin(y/sf[0]-t*tf[0]),-1,1,-c/m,c/m)
c3 = map(sin(y/sf[1]+t*tf[1]),-1,1,-c/m,c/m)
c4 = map(sin(y/sf[1]-t*tf[1]),-1,1,-c/m,c/m)
fill(c1 + c2 + c3 + c4)
rect(-width/2, 250-y, width, 1)
}
// localizing to arm
fill(0)
rect(28, 0, 100, height)
for (let b=0; b<125; b++) {
fill(0, pow(b, 0.6))
rect(b, -height/2, 125, height)
}
for (let b=0; b<125; b++) {
fill(0, pow(b, 0.4))
rect(-width/2, b, width, 125)
}
image(body,-width/2,-height,width*2.5,height*2.5)
}