Is there an easiest way to rotate a line?
Here's my attempt! but doesn't work, freezes at most and no draws solid lines (no rotation)
Code:
case WM_PAINT:
while (cntr++ < 180)
{
DrawLine(hdc, ptCenter, SetPOINT(ptCenter, radius), 255, 128, 128);
Sleep(2000);
}
break;
.........
void DrawLine(HDC hdc, POINT ptCenter, POINT coord, int R, int G, int B)
{
HPEN pen, oldPen;
pen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
oldPen = (HPEN)SelectObject(hdc, pen);
MoveToEx(hdc, ptCenter.x,ptCenter.y, NULL);
LineTo(hdc, coord.x, coord.y);
SelectObject(hdc, oldPen);
DeleteDC(hdc);
}
/* Calculate the line points */
POINT SetPOINT(POINT ptCenter, LONG radius)
{
const float Deg2Rad = 0.017453292;
POINT coord;
static int angle=0;
float degInRad;
degInRad = angle*Deg2Rad // Convert degrees to radians
coord.x = ptCenter.x + (cos(degInRad)*(float)radius); // Finds the adjacent value
coord.y = ptCenter.x - (sin(degInRad)*(float)radius); // Finds the hypotenuse value
angle-=5; // Prepare for the next line position (clockwise direction)
return coord;
}