Skip to content

Instantly share code, notes, and snippets.

@ikonst
Created July 27, 2015 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikonst/e4858c1cd307e8fe9050 to your computer and use it in GitHub Desktop.
Save ikonst/e4858c1cd307e8fe9050 to your computer and use it in GitHub Desktop.
XCode Rainbow Print
// Prints rainbow-colored text into the Xcode output window.
// Required the XcodeColors plugin:
// https://github.com/robbiehanson/XcodeColors
void XcodeRainbowLog(const char *str)
{
float hueStep = 1.0 / strlen(str);
float hue = 0.0;
for (char *c = str; *c != '\0'; ++c) {
UIColor *color = [UIColor colorWithHue:hue saturation:1 brightness:0.8 alpha:1];
hue += hueStep;
CGFloat r, g, b;
[color getRed:&r green:&g blue:&b alpha:nil];
printf("\033[fg%d,%d,%d;%c",
(int)(r * 256),
(int)(g * 256),
(int)(b * 256),
c);
}
printf("\033[fg;"); // reset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment