#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Can the ranges set in colorMode have minimum values?

edited January 2018

colorMode() can set maximum values for rgb hsb gray alpha parameters, creating ranges between 0 and the given argument between 1 and 255. Can colorMode() also set minimum values for these parameters?

For example: how could I add a minimum value of 50 to the grayscale for this code? colorMode(RGB, 100)

Tagged:

• edited January 2018

No, colorMode doesn't take a min argument:

What are you trying to express with RGB min 50, max 100? Would that mean that `background(50)` would draw black, and `background(100)` would draw what? Or are you trying to have colors never go below a certain gray value...?

I believe (?) that color math throughout Processing is zero-range based. Depending on what you are trying to do, might be easier to map your color inputs -- or normalize the into a 0-1.0 colorspace:

``````noStroke();
// 1. map 50-100 to default color range 0-255
color c = color(map(75, 50, 100, 0, 255));
fill(c);
rect(0,0,width/2,height);
// 2. normalize 50-100 to the color range 0-1.0
colorMode(RGB, 1.0);
c = color(norm(95, 50, 100));
fill(c);
rect(width/2,0,width/2,height);
``````