Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GDI + Line Drawing + Palette Rotation - Rainbow effect

Status
Not open for further replies.

TouchingVirus

Programmer
Dec 17, 2003
2
0
0
IE
Hey to all here @ tek-tips..

The rainbow effect is what i am looking for here...it is annoying me :)
Code:
//Start of line drawing...
 
// get the graphics device context 
    hdc = GetDC(hwnd);

    // create a random colored pen
    hpen = CreatePen(PS_SOLID,1,RGB(rand()%256,rand()%256,rand()%256));

    // select the pen into context
    old_hpen = SelectObject(hdc,hpen);

    // move to a random postion
    MoveToEx(hdc, rand()%WINDOW_WIDTH, rand()%WINDOW_HEIGHT, NULL);

    // draw a line
    LineTo(hdc,rand()%WINDOW_WIDTH, rand()%WINDOW_HEIGHT);

    // now delete the pen
    SelectObject(hdc,old_hpen);
    DeleteObject(hpen);
    
    // release the device context
    ReleaseDC(hwnd,hdc);
   

// End of line drawing

The above code was taken from "Windows Game Prgoramming For Dummies" and is a random line drawing snippet with random line colors ...

I want to have a window say 320x255, i can create that, but....

i want to draw a horizontal line from 0,0 to 320,0 and i want it to be violet..
i want to draw another horizontal line from 0,1 to 320,1 and i want it to be a lighter shade of violet...

the process continues until i have encorporated violet,indigo,blue,green,yellow,orange & red into the lines..

then a pallete rotation, so that it scrolls and looks like a rainbow,

If my explanation is too longwinded or not clear, i have got a program with the exact effect i can send you, but its a DOS program written in mode13h -> obviously not what i want here :)
 
I think it isn't the best idea ti use GDI. Getter is to use OpenGL or DirectX.

Ion Filipski
1c.bmp
 
I was thinking the same thing, however, i only got to the section on directX last night lol, so i havnt the faintest idea where to start :D

Any assistance on how to do it would be GREATLY appreciated, i really got into programming coz i wanted to do this...and a few other cool techniques :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top