Globals: (Top of Code)[php]
#define PI 3.14159265//Defining what PI is. PI is a Circle
int CenterX = GetSystemMetrics( 0 ) / 2-1;//Gets screen X resolution then cutting it in half to get the center.
int CenterY = GetSystemMetrics( 1 ) / 2-1;//Gets screen Y resolution then cutting it in half to get the center.
LPDIRECT3DDEVICE9 pDevice;
ID3DXLine *pLine;[/php]
Functions:
[php]
void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
D3DRECT rec = { x, y, x + w, y + h };
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}
void DrawCircle(int X, int Y, int radius, int numSides, DWORD Color)
{
D3DXVECTOR2 Line[128];
float Step = PI * 2.0 / numSides;
int Count = 0;
for (float a=0; a < PI*2.0; a += Step)
{
float X1 = radius * cos(a) + X;
float Y1 = radius * sin(a) + Y;
float X2 = radius * cos(a+Step) + X;
float Y2 = radius * sin(a+Step) + Y;
Line[Count].x = X1;
Line[Count].y = Y1;
Line[Count+1].x = X2;
Line[Count+1].y = Y2;
Count += 2;
}
pLine->Begin();
pLine->Draw(Line,Count,Color);
pLine->End();
}
void DrawPoint(int x, int y, int w, int h, DWORD color)
{
FillRGB((int)x, (int)y, (int)w, (int)h, color);
}
void DrawLine(float x, float y, float x2, float y2, float width, DWORD color)
{
D3DXVECTOR2 vLine[2];
pLine->SetWidth( width );
pLine->SetAntialias( false );
pLine->SetGLLines( true );
vLine[0].x = x;
vLine[0].y = y;
vLine[1].x = x2;
vLine[1].y = y2;
pLine->Begin();
pLine->Draw( vLine, 2, color );
pLine->End();
}[/php]
Drawing code:
(Example)
[php]DrawCircle(CenterX-1,CenterY-1,8,8,Red);//Circle
FillRGB(CenterX-13, CenterY, 10, 1,Red,pDevice);//Left line
FillRGB(CenterX+4, CenterY, 10, 1,Red,pDevice);//Right line
FillRGB(CenterX, CenterY-13, 1, 10,Red,pDevice);//Top line
FillRGB(CenterX, CenterY+4, 1, 10,Red,pDevice);//Bottom line
DrawLine(CenterX+15,CenterY+15,CenterX+3,CenterY+3 ,2,Red);// Bottom right to center
DrawLine(CenterX-15,CenterY+15,CenterX-3,CenterY+3,2,Red);//Bottom left to center
DrawLine(CenterX+15,CenterY-15,CenterX+3,CenterY-3,2,Red);//Top right to center
DrawLine(CenterX-15,CenterY-15,CenterX-3,CenterY-3,2,Red);//Top left to center
DrawPoint(CenterX,CenterY,1,1,Green);//Dot point[/php]
Drawing Code:
(Example)
[php]DrawCircle(CenterX,CenterY,8,8,White);
FillRGB(CenterX-20, CenterY, 40, 1,Purple,pDevice);//Purple
FillRGB(CenterX, CenterY-20, 1, 40,Purple,pDevice);
FillRGB(CenterX-17, CenterY, 34, 1,Blue,pDevice);//Blue
FillRGB(CenterX, CenterY-17, 1, 34,Blue,pDevice);
FillRGB(CenterX-14, CenterY, 28, 1,Cyan,pDevice);//Cyan
FillRGB(CenterX, CenterY-14, 1, 28,Cyan,pDevice);
FillRGB(CenterX-11, CenterY, 22, 1,Green,pDevice);//Green
FillRGB(CenterX, CenterY-11, 1, 22,Green,pDevice);
FillRGB(CenterX-9, CenterY, 18, 1,Yellow,pDevice);//Yellow
FillRGB(CenterX, CenterY-9, 1, 18,Yellow,pDevice);
FillRGB(CenterX-6, CenterY, 12, 1,Orange,pDevice);//Orange
FillRGB(CenterX, CenterY-6, 1, 12,Orange,pDevice);
FillRGB(CenterX-3, CenterY, 6, 1,Red,pDevice);//Red
FillRGB(CenterX, CenterY-3, 1, 6,Red,pDevice);[/php]
[Credits to Rusty for basic code]