Created
July 27, 2015 17:30
-
-
Save ikonst/e4858c1cd307e8fe9050 to your computer and use it in GitHub Desktop.
XCode Rainbow Print
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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