How to animate a square with circular movement, varying rotation and scale

//ciclo de vida se translada a processing
float rotate=0;
void setup(){
size(800,800,P3D);
stroke(255);
noFill();
}

void draw(){
//Limpiar el cuadro anterior de dibujo
background(0);
//identity
float tx=width/2;
float ty=height/2;
float tz=0;

//TRANSLATION
PMatrix3D translation= new PMatrix3D(1,0,0,tx,
0,1,0,ty,
0,0,1,tz,
0,0,0,1);

//SCALE
float sx=3;
float sy=3;
float sz=3;
PMatrix3D scale= new PMatrix3D(sx,0,0,0,
0,sy,0,0,
0,0,sz,0,
0,0,0,1);
//Rotar en z
rotate=rotate - 1;
float angle=radians(20 + rotate);
PMatrix3D rotateZ= new PMatrix3D(sin(angle), cos(angle), 0, 0,
cos(angle), -sin(angle), 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
// Moverse en circulo

     //aqui es cuando ya afecta

applyMatrix(translation);
applyMatrix(scale);
applyMatrix(rotateZ);
//DIBUJO DIRECTO (YA NO EXISTE EN VERSIONES RECIENTES DE OPENGL)
beginShape();
vertex(-50,-50);
vertex(50,-50);
vertex(50,50);
vertex(-50,50);

endShape(CLOSE);
}

Hi @Gerardo_DiazL,

Welcome to the forum! :wink:

Please do the following before we can answer:

  • Your post title should be short and straight to the point, post the content of your question in the post itself. (I renamed it)

  • Format your code as described here:

    Format code

  • Describe what doesn’t work with your current code and what you want to do in the end.

2 Likes