Setting alpha for a point in HSB mode

Hi,

I’m trying to change randomly the alpha setting of a point.
Here is a summary of my code

 strokeWeight(10);
  c = color(0,0,0);
  c.setAlpha(random(10));
  stroke(c);
  point(i,j);

I can’t get any kind of graduation in my alpha it’s either full black or nothing at all

the default alpha range for HSB mode is 0 to 1 instead of 0 to 100 for the S and B channels:

Setting colorMode(HSB) lets you use the HSB system instead. By default, this is colorMode(HSB, 360, 100, 100, 1).

so you’ll want to use c.setAlpha(random(1))

1 Like