# Translate PGS Shape

**URL:** <https://discourse.processing.org/t/translate-pgs-shape/32652>\
**Category:** Libraries\
**Created:** [October 6, 2021, 5:30pm UTC](https://discourse.processing.org/t/translate-pgs-shape/32652 "2021-10-06T17:30:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)\
**Post date:** [October 6, 2021, 5:30pm UTC](https://discourse.processing.org/t/translate-pgs-shape/32652/1 "2021-10-06T17:30:45Z")

</div>

Hi friends,

I’m trying to translate a shape with the PGS library.  
But this code give me no results, the shape does’nt move.  
It’s the same problem with all function from `PGS_Transformation` class.  
Where I’m wrong ?

```auto
import micycle.pgs.*;
PShape sh;
void setup(){
  size(256, 256);
  sh = createShape();
  sh.beginShape();
  sh.vertex(20, 160);
  sh.vertex(200, 200);
  sh.vertex(100, 100);
  sh.endShape(CLOSE);
}
void draw(){
  background(128);
  shape(sh);
}
void mousePressed(){
  PGS_Transformation.translateTo(sh, mouseX, mouseY);
}

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [October 6, 2021, 6:48pm UTC](https://discourse.processing.org/t/translate-pgs-shape/32652/2 "2021-10-06T18:48:23Z")

</div>

Hi,

It seems that `PGS_Transformation.translateTo()` is returning a new PShape object and thus, don’t modify the one you gave it.

Try this instead:

```auto
void mousePressed(){
  sh = PGS_Transformation.translateTo(sh, mouseX, mouseY);
}

```

---

<div class="post-metadata">

**Author:** ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)\
**Post date:** [October 7, 2021, 7:14am UTC](https://discourse.processing.org/t/translate-pgs-shape/32652/3 "2021-10-07T07:14:45Z")

</div>

Ok, it was simple thanks for answer.
