Question
Modify your Bronze program so that it will work properly for any size window. You should be able to change the size command at the
Modify your Bronze program so that it will work properly for any size window. You should be able to change the size command at the start of your program to use any reasonable values, and you should still get a good picture that fills the window without changing anything else at all in your program. Immediately after the size command, two built-in height and width variables will magically appear, and will contain the correct values for the size of the window. Try this code to see: size(640,400); println("Canvas width is "+width); println("Canvas height is "+height); The dimensions of a real curling rink are given in feet. The height of the window (the built-in variable height) will always represent exactly 21 feet. So to convert n feet into pixels you would use the conversion formula n*height/21. Be careful to do the operations in that order the multiplication first and then the division. Now your program should use the following measurements in feet: The ice is 16 feet wide. The circles are 1, 4, 8, and 12 feet in diameter. The centre of the circles is 6 feet from the top of the window. Using these numbers, and the number 21 given above, and the built-in height and width variables, create the following 8 variables, and calculate their correct values (all in pixels): centreIce the x coordinate of the centre line of the ice tLine the y coordinate of the centre of all the circles diam1foot, diam4foot, diam8foot, diam12foot the diameters of the four circles iceWidth, iceLeft the width of the ice, and the x coordinate of its left side Modify the drawing commands from the Bronze exercise (the line, rect, and ellipse commands) so that they use only these 8 variables (as well as 0 and height and width, where appropriate). They may contain simple calculations as well. There should be no numbers left in the drawing commands at all, except 0. (There will still be numbers in the fill commands. Thats OK.) Now, no matter what values you put into the size command at the start of the program, the ice should draw correctly. (If the window is too tall and skinny to see the whole width of the ice, you will only see the centre part of it thats OK. Thats what it should do.) Try various values and make sure that it works
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started