[Help] Drawing shape's

Posts 115 of 22 · Page 1 of 2
[Help] Drawing shape's
Can some 1 post all the drawing thing's like drawline drawcircle drawbox and stuff please.... and how to use them,
Ty.
Check codedeamons stickied thread
Il go check it again iam pretty sure it doesnt explain about drawing shape's
edit: just check only drawcrosshair and drawbox.
Quote Originally Posted by wassup40 View Post
Il go check it again iam pretty sure it doesnt explain about drawing shape's
What is there to explain



Code:
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 );
}
Code:
void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, (y + h - px), w, px,    BorderColor, pDevice );
    FillRGB( x, y, px, h,                BorderColor, pDevice );
    FillRGB( x, y, w, px,                BorderColor, pDevice );
    FillRGB( (x + w - px), y, px, h,    BorderColor, pDevice );
}

Code:
void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, y, w, h,        BoxColor, pDevice );
    DrawBorder( x, y, w, h, 1,    BorderColor, pDevice );
}

Code:
void DrawCrosshair(LPDIRECT3DDEVICE9 pDevice, int size, int strong,  D3DCOLOR xcolor)
{
    int iCenterX = GetSystemMetrics( 0 ) / 2;
    int iCenterY = GetSystemMetrics( 1 ) / 2;
    if( iCenterX < 20 && iCenterY < 20 )
    {
        iCenterX = ( GetSystemMetrics( 0 ) / 2 );
        iCenterY = ( GetSystemMetrics( 1 ) / 2 );
    }
    D3DRECT rec2 = { iCenterX- size, iCenterY, iCenterX+ size, iCenterY+ strong};
    D3DRECT rec3 = { iCenterX, iCenterY- size, iCenterX+ strong,iCenterY+ size};
    pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 1000,  0);
    pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 100,  0);
}
Quote Originally Posted by markoj View Post
What is there to explain



Code:
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 );
}
Code:
void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, (y + h - px), w, px,    BorderColor, pDevice );
    FillRGB( x, y, px, h,                BorderColor, pDevice );
    FillRGB( x, y, w, px,                BorderColor, pDevice );
    FillRGB( (x + w - px), y, px, h,    BorderColor, pDevice );
}

Code:
void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, y, w, h,        BoxColor, pDevice );
    DrawBorder( x, y, w, h, 1,    BorderColor, pDevice );
}

Code:
void DrawCrosshair(LPDIRECT3DDEVICE9 pDevice, int size, int strong,  D3DCOLOR xcolor)
{
    int iCenterX = GetSystemMetrics( 0 ) / 2;
    int iCenterY = GetSystemMetrics( 1 ) / 2;
    if( iCenterX < 20 && iCenterY < 20 )
    {
        iCenterX = ( GetSystemMetrics( 0 ) / 2 );
        iCenterY = ( GetSystemMetrics( 1 ) / 2 );
    }
    D3DRECT rec2 = { iCenterX- size, iCenterY, iCenterX+ size, iCenterY+ strong};
    D3DRECT rec3 = { iCenterX, iCenterY- size, iCenterX+ strong,iCenterY+ size};
    pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 1000,  0);
    pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 100,  0);
}
Just line's i want shape's !
Quote Originally Posted by wassup40 View Post

Just line's i want shape's !
Well you can draw a box and a circle with that, are you asking for like Trianlges and Pentagons, etc?
I wanna draw a circle..... and im not gonna spend hour's trying to draw a circle with line's....
Code:
ID3DXLine *pLine;
#define PI 3.14159265

void DrawShape(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();
}
Wi th this you can draw how ever many sides you want now this is a Crosshair source so edit it up a bit to accommodate your needs.

And to draw a circle the numsides would be 50
Quote Originally Posted by C00lGuy View Post
Code:
ID3DXLine *pLine;
#define PI 3.14159265

void DrawShape(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();
}
Wi th this you can draw how ever many sides you want now this is a Crosshair source so edit it up a bit to accommodate your needs.

And to draw a circle the numsides would be 50
How would i use it?

Well... i got it working but it dc's me straight away.
i used this
Code:
DrawShape(500,500,5,10,Green);
if thats right idk why it dc's me.
Quote Originally Posted by wassup40 View Post

How would i use it?

Well... i got it working but it dc's me straight away.
DrawCircle(X,Y,10,50,D3DCOLOR_ARGB( 255, 255 , 0 ,0));
And you D/C because you probably didnt create the line?
Quote Originally Posted by markoj View Post
DrawCircle(X,Y,10,50,D3DCOLOR_ARGB( 255, 255 , 0 ,0));
And you D/C because you probably didnt create the line?
Still dc...
What ya mean create the line what line.
Quote Originally Posted by wassup40 View Post


Still dc...
What ya mean create the line what line.
Actually where are you drawing it?
In renderframe....
Quote Originally Posted by wassup40 View Post
In renderframe....
Lol that tells me nothing, whos base is it?
You must init pLine... ID3DXLINE
Posts 115 of 22 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?