# Scale PShape object centered

**URL:** https://discourse.processing.org/t/scale-pshape-object-centered/15710
**Category:** Coding Questions
**Created:** [November 22, 2019, 8:22am UTC](https://discourse.processing.org/t/scale-pshape-object-centered/15710 "2019-11-22T08:22:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lumicon9](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@lumicon9](https://discourse.processing.org/u/lumicon9)
#### Post date: [November 22, 2019, 8:22am UTC](https://discourse.processing.org/t/scale-pshape-object-centered/15710/1 "2019-11-22T08:22:06Z")

</div>

hi, how can i scale a PShape object centered?

```auto
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();
}

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 22, 2019, 8:42am UTC](https://discourse.processing.org/t/scale-pshape-object-centered/15710/2 "2019-11-22T08:42:58Z")

</div>

possibly this you want see?

```auto
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();
}

```

---

<div class="post-metadata">

### Author: ![lumicon9](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@lumicon9](https://discourse.processing.org/u/lumicon9)
#### Post date: [November 22, 2019, 10:34am UTC](https://discourse.processing.org/t/scale-pshape-object-centered/15710/3 "2019-11-22T10:34:54Z")

</div>

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