Think "rotate". Learn to do the operation with an eraser, a pencil, and paper. Then translate that into code. We'll help you fix it. Read this before you post code. Put it in code tags.