How can you center rotation of PShape created with createShape()?

I have a code that create a PShape object from createShape() method. I have tried to use shapeMode(CENTER) and looking into various forum post in the internet. However my PShape rotation is still at top left corner.

How can I make so that my PShape rotate in the middle of the object?

If I use shapeMode(center) for a PShape object made from loadShape("file.svg") the origin is centered. However, this is not the case if you createShape() for the PShape object.



  • Answer ✓

    you need to show your code

    I guess you need to place the shape over the origin

    so instead of rect 0,0,50,50

    say rect -25,-25,50,50


  • Hey your solution is working. I feel stupid I did not think of that.

    What I did is that I subtract the x and y position with half of the width and the height of the shape. Afterwards, the rotation happen in the middle of the shape.

Sign In or Register to comment.