# What do x,y stand for in rotate()?

playing around making playing cards in codea. wanted to try doing that with just rotate, text, rect and ellipse (so no meshes or images). I don’t get how to use rotate though…

``````Card = class()

function Card:init(x, y, value)
self.x = x
self.y = y
self.w = 100
self.h = 160
self.value = value
end

function Card:draw()
pushStyle()
fill(50,50,50)
rect(self.x, self.y, self.w, self.h)
fontSize(32)
fill(255, 0, 52, 255)
text(self.value, self.x + 30, self.y + 150)
pushMatrix()
rotate(180,self.x+50,self.y+80,0)
text(self.value, self.x + 30, self.y + 150)
popMatrix()
popStyle()
end

``````

Im trying to rotate the text. I’m really not sure what i should set x,y to, but the gist is that the rectangle is a card and the text is the value of the card and it should be mirrored on the other side of it.

@xThomas - Codea rotates around the origin (0,0), so you need to translate to the centre of the card, then rotate, eg

``````pushMatrix()
translate(self.x,self.y)
rotate(180)
--now draw your text here
popMatrix()
``````

The optional x,y,z parameters in the rotate command are for use in 3D. Don’t worry about them in 2D.

Here’s an example of a rotate inside a rotate. Change rotate(-ang) to rotate(ang) for another effect.

``````displayMode(FULLSCREEN)

function setup()
ang=0
end

function draw()
background(0)
fill(255)

pushMatrix()
translate(WIDTH/2,HEIGHT/2)
rotate(ang)
text("example of rotate",0,0)

pushMatrix()
translate(0,200)
rotate(-ang)
text("example of rotate inside of rotate",0,0)
popMatrix()

popMatrix()
ang=ang+.5
end
``````