Hi!
I would like to show and hide this visualization in P5.js with the button that is show, but I do not succeed, even though I tried it the whole evening.
Does someone maybe know how to make this work? (:
This is the code:
Hi!
I would like to show and hide this visualization in P5.js with the button that is show, but I do not succeed, even though I tried it the whole evening.
Does someone maybe know how to make this work? (:
This is the code:
Welcome there,
This is the simplest way:
draw
, and there is no reason to):function draw() {
{
translate(width/2+130, height/2);
for (var i = 0; i < dots.length; i++) {
dots[i].update();
dots[i].show();}
}
}
isShowDots
), and set it to either true
or false
(you will decide what the initial value should be, based on what you want)draw
) within a statement to do it or not:if (isShowDots) {
for (var i = 0...) {...}
}
showDots
function to update the isShowDots
variable. This should only be one line, and I will leave you to figure out how to set up the logic so the variable isShowDots
can be toggled between true
and false
.If you get stuck again, be sure to ask specific questions.
Hope this helps
Thank you very much! I tried it out and eventually it worked out (:
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.