FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Discussion
   General Processing Discussion
(Moderators: fry, REAS)
   When RGB == HSB
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: When RGB == HSB  (Read 1608 times)
rgovostes

rgovostes
When RGB == HSB
« on: Jul 24th, 2004, 11:44pm »

I thought it'd be interesting to see what colors have the same values in RGB and HSB. An obvious one is black, which is RGB(0, 0, 0) and also HSB(0, 0, 0). Here's the script I wrote to find them all:
 
Code:
int x, y, z;
color c;
for(x = 0; x < 256; x ++) {
  for(y = 0; y < 256; y ++) {
    for(z = 0; z < 256; z ++) {
      colorMode(RGB, 255, 255, 255);
      c = color(x, y, z);
      colorMode(HSB, 255, 255, 255);
      if(c == color(x, y, z)) {
        println(x + ", " + y + ", " + z);
      }
    }
  }
}

 
And they are:
 
Code:
0, 0, 0
192, 127, 254
193, 126, 250
194, 125, 247
196, 124, 242
198, 123, 238
199, 122, 235
201, 121, 231
203, 120, 227
204, 119, 225
205, 119, 224
207, 118, 221
209, 117, 218
212, 116, 214

 
Of course, these are subject to rounding by Processing's HSB to RGB converter.
« Last Edit: Jul 24th, 2004, 11:47pm by rgovostes »  
narain


Re: When RGB == HSB
« Reply #1 on: Jul 25th, 2004, 6:41am »

"That lesson certainly ought to be inapplicable elsewhere in life." -- Hobbes
 
 
rgovostes

rgovostes
Re: When RGB == HSB
« Reply #2 on: Jul 25th, 2004, 11:17pm »

Of course, this could be shortened (I think, assuming big endian):
 
Code:
colorMode(HSB, 255, 255, 255);
for(int i = 0; i < 16777216; i ++) {
  color c = color((i >> 16) & 0xff, (i >> 8) & 0xff, i & 0xff);
  if (i == c) println(red(c) + ", " + green(c) + ", " + blue(c));
}

 
(or not, how does one do an unsigned integer in Java?)
« Last Edit: Jul 25th, 2004, 11:56pm by rgovostes »  
narain


Re: When RGB == HSB
« Reply #3 on: Jul 26th, 2004, 4:42am »

According to the Java language's specification, Java only has signed integers.
 
Pages: 1 

« Previous topic | Next topic »