Like the demo given in class, create a web page with a number value that represents the size of a canvas to be created. The size should be square and should range between 300 and 900, inclusive, in increments of 100.The default value should be 500. Also, provide a number value that represents the number of darts to throw at the canvas. Max/min/default values for this field should be same as the other field.
There should be a button labeled “Fire!”. When pressed, the button should cause a gunshot sound to play. Also, it should cause the canvasto be sized, the square and circle drawn, and all darts thrown at random locations on the canvas.
The areas inside and outside the circle should be different colors. Also, the darts inside the circle should be a different color from those outside the circle. Any dart on the circle should be counted as inside.
Print a value at the bottom of the page (not on the canvas) that shows the computation of a value for PI based on the ratio of darts in andout of the circle, as discussed in class.
Reviews
There are no reviews yet.