Low alpha values making transparent fills imperfect

I've got the following code:

void setup() {
  size(400, 400);
  colorMode(RGB,255,255,255,255);
  background(color(51, 85, 204));
  noStroke();  
}

void draw() {
  fill(color(255), 1);
  rect(0,0,width/2, height);
  fill(color(255), 100);
  rect((width/2) - 10, (height/2) - 10, 20, 20); 
}

My expectation is that the alpha value on the left rect would result in a transparent rectangle that gradually fades to white, but it seems to stop at an off-white. Increasing the alpha gets it closer to white, but any low value (below 35 or so) seems to result in an imperfect fading effect.

Is this just a result of the color values being integers rather than floats, or is there something else going on? And is there any way to fix this, other than just increasing the alpha?

Answers

Sign In or Register to comment.