objective-ciphoneansi-colors

8 bit color in iPhone


I'm playing with ANSI escape sequences and i'm having a rough time with colors.

I've tried with a couple of color palettes from Wikipedia's ANSI entry, and it always happens the same. I create a color with

[UIColor colorWithRed: green: blue: alpha];

And the result has nothing to do with the supposed colors (i divide each of them by 256), most of them ending up the same. I believe UIColor is not enough and i should use CGColorRef in order for making the translation. Any tips?

this is the result

The top colors are the "regular ones" and the lower ones are supposed to be the brighter eight, but everything is messed up.

This is how i create the colors:

+ (UIColor *) cyanANSIColor
{
    return [UIColor colorWithRed:51.0f/256.0f 
                             green:187.0f/256.0f
                             blue:200.0f/256.0f
                             alpha:1.00f];
}

+ (UIColor *) brightCyanANSIColor
{
    return [UIColor colorWithRed:85.0f/256.0f
                             green:255.0f/256.0f
                             blue:255.0f/256.0f
                             alpha:1.00f];
}

And i assign them to each view vía it's

backgroundColor

property. You can see the cyan colors are wrong (one of them), and most of them look the same. A dark gray shows blue. And none is an int.


Solution

  • This is what I get when I manually set the colors of two views to the values specified in the question:

    enter image description here

    My "normal" cyan (51,187,200) is at the top and the bright (85,255,255) is at the bottom. But according to the way the colors look my top color matches your bottom color. Is it possible that you have not drawn the swatches in the correct location, and thus are seeing the background of the view for the cyan? And that the other swatches are similarly misdrawn?