I am currently utilizing the p5.js library to work on a program that is designed to automatically fill closed spaces. However, I am encountering an issue where the program sometimes fills half-closed loops for reasons unknown to me. If anyone could provide assistance in pinpointing the problem, I would greatly appreciate it.
Here is an example illustrating the issue: https://i.sstatic.net/alfgW.png
To observe the problem, you need to zoom in significantly; otherwise, it breaks (on a side note, any guidance on scaling up the pixels would also be valuable).
let pixelVals;
let checkedPixels;
let filledPixels;
let iter = 0;
let drawFilled;
function setup() {
pixelVals = array(height, width, 4);
createCanvas(25, 25);
pixelDensity(1);
// Additional code for setting initial values
}
// Further functions and definitions...
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
Apologies for the messy JavaScript code as I am still new to this language :)
// Additional code snippet
function setFilledFalse() {
// Code implementation...
}
function array(length) {
// Array function definition...
}
Thank you in advance,
Zac