Here is my code to draw a cube like color box. I am not sure, if there is another or better way to generate/draw this colored cube. Most graphic programs are using a more rotated colorCube ^^ If you are interested, how i found out the math to draw this cube, i downloaded an original colorCube as PNG from google. Then i extracted each color channel and saved this as own image. So i managed to see how are the gradients and how to start coding my colorCube step by step.
long bufferColor[256 * 256];
// Clear Background
for (int i = 0; i < 256 * 256; i++)
{
bufferColor[i] = RGB(64, 64, 64);
}
// Draw ColorCube (routine by va!n)
for (int y = 0; y < 128; y++)
{
for (int x = 0; x < 128; x++)
{
bufferColor[(64 + x - (y / 2) + (y * 256))] = RGB(x * 2, 255, y * 2);
bufferColor[x + (y / 2) + ((y + 128) * 256)] = RGB(x * 2, 256 - (y * 2), 255);
bufferColor[128 + 64 + (x / 2) - (y / 2) + (y + x) * 256] = RGB(255, 256 - (x * 2), y * 2);
}
}