# Repeated alpha not reaching full opacity

**URL:** https://discourse.processing.org/t/repeated-alpha-not-reaching-full-opacity/16890
**Category:** Coding Questions
**Created:** [January 6, 2020, 3:16am UTC](https://discourse.processing.org/t/repeated-alpha-not-reaching-full-opacity/16890 "2020-01-06T03:16:56Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![mortap](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@mortap](https://discourse.processing.org/u/mortap)
#### Post date: [January 8, 2020, 6:19pm UTC](https://discourse.processing.org/t/repeated-alpha-not-reaching-full-opacity/16890/7 "2020-01-08T18:19:32Z")

</div>

That works:

```auto
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);
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/repeated-alpha-not-reaching-full-opacity/16890)._
