1

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.

1
  • 1
    On the plus side, black looks good. Apr 4, 2012 at 20:24

1 Answer 1

2

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.

2
  • I kind of figured this was this issue. I'm trying a bunch of different styles. I really like the effect it gives, just wish the colors weren't screwed up Apr 5, 2012 at 15:10
  • 1
    Awesome, thanks! I haven't got them all to exactly where I wanted, but with some messing around I'm steadily fixing it. Apr 5, 2012 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.