# Need some help with translate() and rotate()

**URL:** <https://discourse.processing.org/t/need-some-help-with-translate-and-rotate/35372>\
**Category:** Processing.py\
**Created:** [February 22, 2022, 6:59am UTC](https://discourse.processing.org/t/need-some-help-with-translate-and-rotate/35372 "2022-02-22T06:59:23Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 22, 2022, 1:55pm UTC](https://discourse.processing.org/t/need-some-help-with-translate-and-rotate/35372/3 "2022-02-22T13:55:49Z")

</div>

Hello @adora,

You are rotating about the corner of the shape.  
Translate it after the rotation to center it.

Example:

```auto

def setup():
    size(300, 300)

x = 0
def draw():
    global x
    background(255)
    
    translate(width/2, height/2) # (0, 0) is center of canvas
    
    strokeWeight(2);
    rotate(radians(x))
    #translate(-50, -25) #uncomment this
    
    fill(255, 0, 0);
    noStroke()
    
    beginShape()
    rect(0, 0, 100, 50);
    fill(0); #black
    circle(0, 0, 10); #corner of rectangle   
    fill(255, 255, 0); #yellow
    circle(50, 25, 10); # (50, 25) is center of rectangle    
    endShape()
    
    x = x+1

```

I did the same for this example with an image:  
_[Help in Rotate Image in JAVA2D - #4 by glv](https://discourse.processing.org/t/help-in-rotate-image-in-java2d/33852/4)_

`:)`

---

_[View the full topic](https://discourse.processing.org/t/need-some-help-with-translate-and-rotate/35372)._
