Hello, I was hoping to solve this one all by myself but I am stumped. Made loads of attempts at changing the code and cant work out for the life of me how to do it (Probably really simple)


I am rotating a rectangle to draw to the screen. At the moment I want to it rotate around its center so it spins on the spot. I have the code to rotate the rectangle I just cant center, it rotates around its top left corner

Code:
	
/*StartX, StartY, Width and Height are passed in as the grid coords for the start of the rectangle and its size. I want to rotate it around its StartX + (Width / 2) as this will be the center of the drawn rectangle
*/
int x;
int y;
int NewX;
int NewY;

for (x=0; x<Width; x++)
   {
   for (y=0; y < Height;y++)
   {
	
            //Rotate Points
	NewX = (x * cos(Angle)) - (y * sin(Angle));
	NewY = (x * sin(Angle)) +  (y * cos(Angle));
				
				
	//Write to buffer
	GRIFFIN_DrawPixel(NewX + StartX, NewY + StartY, Color);
    }	            
}
Anyone know what I am doing wrong

Thanks for looking