Question: how to create global variable that initially holds an empty array. This array will be a 2d array that will store arrays of [x,y] coordinates.

how to create global variable that initially holds an empty array. This array will be a 2d array that will store arrays of [x,y] coordinates.

Then, how tocreate an onclick event handler on the canvas so that every time the canvas is clicked the following things happen: Get the x and y coordinate of the click that just occurred (hint: offsetX and offsetY) Create an array that contains the [x,y] coordinate and push it into the global array Then draw and fill a circle of radius 10 centered at this (x,y) coordinate Upon completing this step, when you click on the canvas three times your canvas should look like:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!