hi! welcome to the forum!
please format your code with </> button so it’s easier to see and copy/paste. also if you can provide example images, that would be better.
what I see in Tim’s video is that when greyscale value is high (or low, I don’t know), the z position of the boxes change - plus, the sizes change at certain threshold. regarding your question with sin()
as well, I think they are using easing functions to make smooth change. There are libraries like Ani but I found they are confusing so I adapted easing functions from processing-penner-easing/src at master · jesusgollonet/processing-penner-easing · GitHub
// adapted from https://github.com/jesusgollonet/processing-penner-easing/tree/master/src
float easeInOutLinear (float t) {
float b = 0, c = 1, d = 1;
return c*t/d + b;
}
float easeInOutQuad(float t) {
float b = 0, c = 1, d = 1;
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
}
float easeInOutCubic (float t) {
float b = 0, c = 1, d = 1;
if ((t/=d/2) < 1) return c/2*t*t*t + b;
return c/2*((t-=2)*t*t + 2) + b;
}
float easeInOutQuart(float t) {
float b = 0, c = 1, d = 1;
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
return -c/2 * ((t-=2)*t*t*t - 2) + b;
}
float easeInOutQuint (float t) {
float b = 0, c = 1, d = 1;
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
}
void setup() {
size(800, 800);
}
void draw() {
background(0);
float T = millis() * 0.001;
float t = (T / 2) % 2;
if (t > 1) t = 2 - t; // back and forth
float ystep = height / 10;
float r = 100;
push();
{
translate(0, ystep);
float x = easeInOutLinear(t);
ellipse(x * width, 0, r, r);
translate(0, ystep);
}
{
translate(0, ystep);
float x = easeInOutQuad(t);
ellipse(x * width, 0, r, r);
translate(0, ystep);
}
{
translate(0, ystep);
float x = easeInOutCubic(t);
ellipse(x * width, 0, r, r);
translate(0, ystep);
}
{
translate(0, ystep);
float x = easeInOutQuart(t);
ellipse(x * width, 0, r, r);
translate(0, ystep);
}
{
translate(0, ystep);
float x = easeInOutQuint(t);
ellipse(x * width, 0, r, r);
translate(0, ystep);
}
pop();
push();
translate(width / 2, 0);
rectMode(CENTER);
{
translate(0, ystep);
push();
float x = easeInOutLinear(t);
rotate(x * PI * 2);
rect(0, 0, r, r);
pop();
translate(0, ystep);
}
{
translate(0, ystep);
push();
float x = easeInOutQuad(t);
rotate(x * PI * 2);
rect(0, 0, r, r);
pop();
translate(0, ystep);
}
{
translate(0, ystep);
push();
float x = easeInOutCubic(t);
rotate(x * PI * 2);
rect(0, 0, r, r);
pop();
translate(0, ystep);
}
{
translate(0, ystep);
push();
float x = easeInOutQuart(t);
rotate(x * PI * 2);
rect(0, 0, r, r);
pop();
translate(0, ystep);
}
{
translate(0, ystep);
push();
float x = easeInOutQuint(t);
rotate(x * PI * 2);
rect(0, 0, r, r);
pop();
translate(0, ystep);
}
pop();
}
you can see that the lower ones’ movements are more crisp and human like… note that you have to clamp the input values of easeInOut*
always between 0 to 1.