I'm having some weird colour issues in an Android project I'm working on. Everything works fine in Standard mode but misbehaves in Android mode. Whilst trying to debug the issue, I realised that HSB colorMode behaves differently in Android mode than Standard mode.
I've condensed the issue into a small sketch. The comments describe exactly the problem and how to duplicate it. If anyone can offer an explanation for the color inconsistencies between Android and Standard modes, it may help me to identify the issue in my sketch.
Thanks.
[EDIT] I discovered another clue. The colour change seen in case 4 in the sketch is *always* the same. i.e. it doesn't seem to matter what rgbColor is set to, it will be rendered pink if the HSB conversion is done.
- /*
- * Inconsistent HSB behaviour in STANDARD & ANDROID modes?
- * To replicate:
- *
- * Compile in STANDARD mode
- * 1) set useRGB = true. Compile. Note colours (screen grab if necessary)
- * 2) set useRGB = false. Compile. Note colours are the same (compare screen grab if necessary)
- *
- * Compile in ANDROID mode
- * 3) set useRGB = true. Compile. Note colours (screen grab if necessary)
- * 4) set useRGB = false. Compile. Note colours are DIFFERENT!! (compare screenshot if necessary)
- */
- color backgroundColor = #231000;
- color rgbColor = #66ffff;
- color fillColor;
- boolean useRGB = false;
- void setup() {
- //size( 500, 500 ); // use for STANDARD compiler
- noStroke();
- }
- void draw() {
- background( backgroundColor );
- rectMode(CENTER);
- translate( width/2, height/2 );
- if( useRGB ) {
- fillColor = rgbColor;
- } else {
- // all we do when useRGB == false is change colorMode to HSB, grab HSB components,
- // recreate colour, revert colorMode back to RGB
- colorMode( HSB, 255 );
- float h = hue( rgbColor );
- float s = saturation( rgbColor );
- float b = brightness( rgbColor );
- fillColor = color(h, s, b);
- colorMode( RGB, 255 );
- }
- fill( fillColor );
- rect( 0, 0, 200, 200 );
- }
1