Question about rotations

I have a question about rotations in Codea.
Is there a way not to change the x and y coordinates while rotating?
If I use for example rotate(90) it rotates the sprite, but by doing this it changes its coordinates so it is sometimes out of the screen.
I would like to rotate the sprite around its center.
I searched the forum but haven’t find an answer yet.
Thanks for answers in advance.

You need to translate to its position. For example, to draw a sprite rotated 90° you can do:

translate(WIDTH/2, HEIGHT/2)
sprite("Documents:WhateverSprite", 0, 0, whateverWidth)

That’s exactly what I wanted :slight_smile:

@Leon just be careful because the order of operations matters

So this:

translate(WIDTH/2, HEIGHT/2)

Means something different from this:

translate(WIDTH/2, HEIGHT/2)

A good general rule is to read the transform operations from the bottom up, because that is the ‘order’ in which they will apply.

@Leon - I explain it here

I also have some eBooks on the Index page

Thanks again :slight_smile:
I’ll read it immediately