processing / p5.js-web-editor

The p5.js Editor is a website for creating p5.js sketches, with a focus on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else! You can create, share, or remix p5.js sketches without needing to download or configure anything.
https://editor.p5js.org
GNU Lesser General Public License v2.1
1.3k stars 1.26k forks source link

background with alpha unexpected behavior #3128

Closed jacopomazzoni closed 1 month ago

jacopomazzoni commented 1 month ago

p5.js version

1.9.3

What is your operating system?

Windows

Web browser and version

Brave ( chrome ) 1.66.110 Chromium: 125.0.6422.60 (Official Build) (64-bit)

Actual Behavior

for alpha values < 25 in background some shapes are never fully overwritten

ie: background(0,5) has the issue background(0,25) does not

Expected Behavior

any shape after a certain amount of frames depending on its color should be wiped away by enough overlays no matter how small the transparency

Steps to reproduce

Steps:

  1. run this MRE and look at the circle never disappearing
  2. change values and observe that ~25 depending on browser and os is the threshold value for shapes finally disappearing
  3. fix implementation?

    Snippet:

// https://editor.p5js.org/jacopom/sketches/RU0kHMjnG function setup() { createCanvas(400, 400); background(0);

}

function draw() {

background(0,5); fill(255); stroke(255); if(frameCount == 1 ) { ellipse(width/2,height/2,100); } fill(0); rect(0,0,100,30); fill(255); text("Frame: " + frameCount,20,20);

// / 5 out of 255 alpha / / expected behaviour 255/5 = 51 / / in 51 cycles a white value of / / 255 should be reduced to 0 / / let's test it! / / in reality for any value <~25 this does not happen / / and a faint white dot remains visible forever / // }

welcome[bot] commented 1 month ago

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

jacopomazzoni commented 1 month ago

I messed up I thought I was opening an issue on the library page, sorry close this.