fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.41k stars 357 forks source link

How to rotate a Rectangle in it center? #127

Open jdxyw opened 3 years ago

jdxyw commented 3 years ago

Hi, I am trying to rotate a Rectangle in its center, but it seems doesn't work, below is the code. Anyone knows what's wrong with it?

Thanks!

var sideLen float64 = 10
ctex.Push()
ctex.SetColor(cl)
ctex.Translate(x0, y0)
ctex.Rotate(gg.Radians(float64(theta)))
ctex.DrawRectangle(-sideLen/2,sideLen/2,sideLen,sideLen)
ctex.Fill()
ctex.Pop()
fogleman commented 3 years ago

Try Rotate before Translate