Repeated alpha not reaching full opacity

That works:

float x0, y0;
float angle0;
float radius = 5; 
int bg = 255;
int alph = 3;

void setup() {
  size(500, 500);
  background(bg);
  x0 = random(width);
  y0 = random(height);
  angle0 = random(360);
  fill(255, 0, 0, 255);
  ellipse(x0, y0, 50, 50);
}

void draw() {
  //blendMode(ADD);  //uncomment this to compare
  noStroke();
  fill (bg, bg, bg, alph);
  rect(0, 0, width, height);
  
  blendMode(BLEND);
  
  float x1 =  x0 + cos(radians(angle0)) * radius;
  float y1 =  y0 + sin(radians(angle0)) * radius;
  stroke(0);
  line(x0, y0, x1, y1);
   
  x0 = x1;
  y0 = y1;
   
  if ((x0 > width) || (y0 > height) || (x0 < 0) || (y0 < 0)) {
    x0 = random(width);
    y0 = random(height);
    angle0 = random(360);
  }
}
2 Likes