Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
v1.11.1
Web browser and version
Mozilla Firefox 136.0 (and others)
Operating system
Linux (and others)
Steps to reproduce this
idw if is actually a bug, but i notice a very different behavior when running a simple sketch on normal and private mode of Firefox. in case im looping trough the .pixel
array of a tiny image created with the createImage()
function and put them on a both DOM's paragraphs (after converting to binary and hexadecimal values). a mousePressed()
function update the image and call the functions that update the paragraphs.
the strange part is that even in the online editor, as in a version hosted locally on my computer, or hosted on a github page i notice the following: in a normal firefox window everything goes as expected. but on a private tab strange results appear in the paraphs.
links to the both online editor and github pages versions:
Steps:
- open the links above on normal and incognito modes
- click repeatedly on any of the withe squares
- check the results on binary and hex paragraphs on each mode
the source on both versions are on the following links, but ill paste the related functions
Snippet:
function mousePressed() {
if(mouseX < 25 || mouseX > 375 || mouseY < 25 || mouseY > 375)
return;
let cellSize = 350 / 8;
let x = Math.floor((mouseX - 25) / cellSize);
let y = Math.floor((mouseY - 25) / cellSize);
grid.set(x, y, selectedColor);
grid.updatePixels();
updateBits();
updateHexs();
}
function updateBits(){
bitsStr = "";
grid.loadPixels();
for(let i = 0; i < grid.pixels.length; i = i + 1){
if((i % 4) == 3)
continue;
bitsStr += Number(grid.pixels[i]).toString(2).padStart(8, "0") + " ";
}
grid.updatePixels();
if(selector.active){/*weird string manipulation to highlight parts of <p>*/}
bitsP.html(bitsStr);
}
function updateHexs(){
hexStr = "";
grid.loadPixels();
for(let i = 0; i < grid.pixels.length; i = i + 1){
if((i % 4) == 3)
continue;
hexStr += hex(grid.pixels[i], 2) + " ";
}
grid.updatePixels();
if(selector.active){/*weird string manipulation to highlight parts of <p>*/}
hexsP.html(hexStr);
}