the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > the cause of the problem is buttons[0].addEventListener("click",draw(context,image1.path,image1.xpos,image1.ypos,image1.height,image1.width)); The draw function in this line of code is actually executed immediately, rather than being called when the button is clicked. This is because the second argument passed to addEventListener should be a function, not the result of a function call.
To fix this, change this line of code to the following form:
buttons[0].addEventListener("click", function() {
draw(context,image1.path,image1.xpos,image1.ypos,image1.height,image1.width);
});
This way, the draw function is not executed immediately when the code loads, but is called only when the button is clicked.