ColorMode and ARGB values

Just trying to figure out whats going on behind the scenes when using colorMode.

it can be set to greater than 255, however the values retrieved from it are then not accurate. And it doesnt seem to have a definitive conversion factor.

color bg;

void setup() {
  size(100, 100);
  //colorMode(HSB, 360, 100, 100);
  colorMode(RGB,1000);
  bg = color(180, 50, 50);
  println("col",red(bg));
}

void draw() {
  background(bg);  
}
2 Likes

Hello,

I usually start here to see what these Processing helper functions are doing:
https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java

And I see that this import java.awt.color.ColorSpace; is used:
https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L44
https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html

:)

thanks after further experiments I saved a file with values from 0,100000 in their color counterpart and it seems that the values are simply mapped with a modulus function. I was hoping the color space would be able to map individual values but unfortunately it doesnt function this way.

this is a sample of the output file and we can see that the color space is unable to provide individual values for each index.

92.1569, 364
392.1569, 365
392.1569, 366
392.1569, 367
392.1569, 368
392.1569, 369
392.1569, 370
392.1569, 371
392.1569, 372
392.1569, 373
392.1569, 374
392.1569, 375
392.1569, 376
392.1569, 377
392.1569, 378
392.1569, 379
392.1569, 380
392.1569, 381
392.1569, 382
392.1569, 383
392.1569, 384
784.3138, 385
784.3138, 386
784.3138, 387
784.3138, 388
784.3138, 389
1 Like

Thanks for the help. In the end I’ve created a base 256 converter, this way I can fully utilise the range provided by the color() method and can therefore read and write numbers to later manipulate with shaders.

1 Like