Scale PShape object centered

hi, how can i scale a PShape object centered?

PShape square;  
float shrink;
float sizeXY=100;

void setup() {  
  size(300, 300);
  square = createShape(RECT, 0, 0, sizeXY, sizeXY);
}

void draw() {
  shrink=shrink+0.01;
  shapeMode(CENTER);
  pushMatrix();
  scale(1-shrink,1-shrink);
  shape(square, width/2-sizeXY/2, height/2-sizeXY/2);
  popMatrix();
}
1 Like

possibly this you want see?

PShape square;  
float shrink;
float sizeXY=100;

void setup() {  
  size(300, 300);
  square = createShape(RECT, -sizeXY/2, -sizeXY/2,sizeXY,sizeXY);
}

void draw() {
  translate(width/2,height/2);
  shrink=shrink+0.01;
  pushMatrix();
  scale(1-shrink);
  shape(square);
  popMatrix();
}

2 Likes

perfect! thank you!
…make the left-upper-corner scaling-pivot the center of the object and later translate…, without effecting this centerpoint. great!

1 Like