gg icon indicating copy to clipboard operation
gg copied to clipboard

How to rotate a Rectangle in it center?

Open jdxyw opened this issue 5 years ago • 1 comments

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()

jdxyw avatar Mar 01 '21 09:03 jdxyw

Try Rotate before Translate

fogleman avatar Mar 01 '21 14:03 fogleman