Jason McMaster
Jason McMaster

Reputation: 103

Colors in app different than the image they're based on

I'm creating a coloring book app for a client and it's coming along well. Very well, in fact, because it's finished. However there's one snag: some of the colors aren't displaying as expected.

The client gave me images and a key to use for the brush creation. I took the color reference and made several different sizes of circle to use, for each color, to represent different brush sizes. I then load the brush as so:

    brush = [[CCSprite spriteWithFile:@"yellowbrush3.png"] retain];
    [brush setBlendFunc: (ccBlendFunc) { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }];  
    [brush setOpacity:20];

The brush image for this particular file is:

Yellow brush

I made a screenshot of the colors output to compare with the key I used to create the brushes:

Several color swatches

About half of the colors show up just fine while the others are pretty noticeable.

I've tried different levels of opacity, changing some GL settings, but nothing seems to help.

Upvotes: 1

Views: 148

Answers (1)

Sam
Sam

Reputation: 2579

This is due to a blending artifact and the fact that you are drawing on a white background. To confirm this, alter the background color and see that the hue for each color changes slightly. To correct this issue you can reduce the opacity of the painted colors, or pick a more appropriate blending mode.

Try changing your glBlendFunc to use GL_ONE for both parameters. This will remove the blending but at least your colors should be 100% accurate.

Upvotes: 2

Related Questions