Skip to content

Instantly share code, notes, and snippets.

@purpleposeidon
Forked from tene/colorcube.c
Created March 28, 2010 05:35
Show Gist options
  • Save purpleposeidon/346594 to your computer and use it in GitHub Desktop.
Save purpleposeidon/346594 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int rgb(int r, int g, int b) {
return 16 + r*36 + g*6 + b;
}
int main() {
for (int r = 0; r < 6; r++) {
for (int g = 0; g < 6; g++) {
for (int b = 0; b < 6; b++) {
printf("\e[38;5;%dm", rgb(r,g,b));
for (int bgr = 0; bgr < 6; bgr++) {
for (int bgg = 0; bgg < 6; bgg++) {
for (int bgb = 0; bgb < 6; bgb++) {
printf("\e[48;5;%dm#", rgb(bgr,bgg,bgb));
}
}
printf("\e[0m\n");
}
}
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment