# Why does empty draw() function change canvas?

**URL:** <https://discourse.processing.org/t/why-does-empty-draw-function-change-canvas/23679>\
**Category:** Beginners\
**Created:** [September 4, 2020, 3:10pm UTC](https://discourse.processing.org/t/why-does-empty-draw-function-change-canvas/23679 "2020-09-04T15:10:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_riptano](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mr\_riptano](https://discourse.processing.org/u/mr_riptano)\
**Post date:** [September 4, 2020, 3:10pm UTC](https://discourse.processing.org/t/why-does-empty-draw-function-change-canvas/23679/1 "2020-09-04T15:10:15Z")

</div>

```auto
void setup(){
  size(400,400);
  background(0);
  paint(200,200,150,10);
}

void draw()
{
}

void paint(float x, float y, float r, float v){
  noFill();
  strokeWeight(v);
  stroke(250,180,0,10);
  ellipse(x,y,r,r); 
}

```

Produces:

![test](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8e8cc69448d3ee613687f97eaf338c3470a614fd.png)

This is not a completely black square! It’s like the yellow circle was drawn as desired, then covered with a mostly-but-not-entirely-opaque black overlay.

If I move the paint() call into draw(), then I get the expected result of a very obvious yellow circle. (PNG omitted because I’m getting “new users can only have one attachment” error.)

Why is an empty draw() changing the canvas?

ETA: p5js behaves the same way.

---

<div class="post-metadata">

**Author:** ![Spaceman1](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/spaceman1/32/9970_2.png) [@Spaceman1](https://discourse.processing.org/u/Spaceman1)\
**Post date:** [September 4, 2020, 3:41pm UTC](https://discourse.processing.org/t/why-does-empty-draw-function-change-canvas/23679/2 "2020-09-04T15:41:53Z")

</div>

Its not really dependent on the function not being called in draw. What’s happening is that you are setting the stroke to be transparent. The stroke function, when passed 4 arguments,the last parameter is called alpha, and lower values (in your case the number 10) are more transparent. To fix this just put 3 parameters (The RGB) in stroke.

The reason this problem is fixed when you put the paint function in draw is that draw is running hundreds of times, creating layers of semi-transparent circles which then becomes opaque.
