I’m trying to make a color gradient (blue to white, left to right) using C++ (DarkGDK Library). I’m trying to accomplish this using nested for loops.
Here’s what I have so far:
#include "DarkGDK.h"
void DarkGDK()
{
int colorDepth = dbScreenDepth();
dbSetDisplayMode(256,256,colorDepth);
dbClear(0,0,255);
for (int y = 0; y < 255; y++)
{
for (int x = 0; x < 255; x++)
{
}
}
dbWaitKey();
}
I can’t figure out what to do to make the red and green values go up by 1 each time an iteration is made. I’ve been staring at this for 3 hours and have made no progress…
Any help would be appreciated.
The method you need is dbInk(), with dbRGB() inside it, and you missed the while loop, which is important when using this library.
what this does, is that it scans the screen horizontally, drawing a straight line from the top of the screen to the bottom from left to right, using the variabe x, with the for loop.
Since white is 255,255,255 or 0xFFFFFF, and you want it to go from blue to white, you have to add 1 to red and green so that it goes all the way to white.
if you were to take it from blue to black, as another example, you would replace dbInk() with
try it, and have fun coding.