1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
do
{
//draw a background color:
for(int y=0; y<ConsoleHeight; y++)
{
for(int x=0, i=0; x<ConsoleWidth; x++)
{
PixelColors[y*ConsoleWidth + x] = RGB(0,0,255);
}
}
Angle.PosZ += 0.2;
RotOrigin = RotationPoints(Origin,RotatePoint,Angle);
RotDestination = RotationPoints(Destination,RotatePoint,Angle);
GetLineDots = GetLinePoints(RotOrigin,RotDestination);
// draw a line:
for(int x=0; x<GetLineDots.size()-1; x++)
{
int Index=GetLineDots[x].PosY*ConsoleWidth + GetLineDots[x].PosX;
if (Index<0 || (GetLineDots[x].PosY>=ConsoleHeight && GetLineDots[x].PosY<0 && GetLineDots[x].PosX>=ConsoleWidth && GetLineDots[x].PosY<0) ) continue;
PixelColors[Index] = RGB(0,255,0);
}
// draw the pixels on console window:
StretchDIBits(HDCConsoleWindow,0,0,ConsoleWidth, ConsoleHeight, 0,0, ConsoleWidth,ConsoleHeight, BufferMemory, &BitInfo,DIB_RGB_COLORS, SRCCOPY );
Sleep(50);
}while(!GetAsyncKeyState(VK_ESCAPE));
|