Question: A Point constructor that creates Point objects. Replace all the x and y coordinate global variables with Point objects. Update all the references to these
A Point constructor that creates Point objects. Replace all the x and y coordinate global variables with Point objects. Update all the references to these variables in your code to now use the point objects. 4. Refactor the findMid function so that it is a method in the Point constructor. The method should now accept one Point object as a parameter. Let's look at an example usage of this method. Given the following two points: let p1 = new Point(0,250); let p2 = new Point(500,500); We will be able to call p1.findMid(p2); and it will return the midpoint between p1 and p2, as a Point object. 5. Update all the function calls to the findMid function to now use the method you created in the previous step. 6. a function called selectColor(). This function should check if the Randomize Colors checkbox is selected. If it is, return a random color. If it is not selected, return black.7. [1] Modify your executeProgram() function to fill the circle with whatever color is returned by calling the selectColor() function. 8. Setup a function that creates an interval such that every 100ms the executeProgram() function runs. 9. Setup the event handler so that when the 10 Rolls Per Second! button is clicked, the interval starts. Make sure that if the user presses this button multiple times, the interval does not run multiple times. 10. Set up the event handler so that when the Stop Rolling! button is clicked, the interval stops executing. 11. Set up an event handler so that pressing the space bar toggles on and off the interval
Uploaded is my version before these questions


File Edit Selection View Go Run Terminal Help JS chaos.js project A1 > JS chaos.js > pushr Q 1 2 let canvas = document.getElementById("myCanvas"); 3 let ctx = canvas.getContext("2d"); 4 5 let x1 = 250 6 let y1 = 0 7 let x2 = 500 8 let y2 = 500 9 let x3 = 0 10 let y3 500 11 12 13 14 function roll() { return Math.round(Math.random() *5)+1 15 16 17 18 19 function findMid(x1,y1,x2,y2) { x4 = (x1+x2)/2 20 34 = (y1+y2) 12 21 return { 22 x:x4, 23 y: y4 24 25 } 26 27 28 let point findMid(x1,y1,x2,y2); console.log(point.x) 29 30 31 let halfx (point.x) 32 let halfy = (point.y) 33 34 function execute Program() { 35 36 let num (Math.round(Math.random()*5)+1) 37 38 39 if (num=1||num==2) { 40 41 42 43 44 let point = find Mid(x1,y1,halfx, halfy) ctx.beginPath(); ctx.arc(point.x,point.y,2,0,2*Math.PI) ctx.fill(); 45 halfx point.x; 46 halfy point.y; 47 48 25C Sunny } chaos.js - 1045 - Visual Studio Code Q 0 1 Ln 86, Col 5 (17 selected) Spaces: 4 UTF-8 CRLF { JavaScript Go Live Prettier ENG US 5:01 PM 2022-08-04
Step by Step Solution
There are 3 Steps involved in it
Combining Information from Images and Steps Based on the information you provided from the two images and the breakdown of steps heres how to solve the problem 1 Replace Global Variables with Point Ob... View full answer
Get step-by-step solutions from verified subject matter experts
