Translate PGS Shape

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 ?

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);
}
1 Like

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:

void mousePressed(){
  sh = PGS_Transformation.translateTo(sh, mouseX, mouseY);
}
2 Likes

Ok, it was simple thanks for answer.