Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2/18/2021 CSC110 - HWE 2/18/2021 CSC110 - HWE Look at Figures 1, 2, and 3. I will refer to each of these as one line

image text in transcribedimage text in transcribedimage text in transcribed

2/18/2021 CSC110 - HWE 2/18/2021 CSC110 - HWE Look at Figures 1, 2, and 3. I will refer to each of these as one line grid Drawings Objectives Working with loops Continued practice with functions definitions and if statements Each line grid is made up of a sequence of straight lines. . Given the coordinates of the top line left endpoint and the width, you should be able to figure out the coordinates of the right endpoint of that top line. Successive lines are drawn with shifted endpoints. The amount of space between each horizontal line is based on the width and number of lines. Each grid should have the same height as its width. For this assignment you'll be using the Gui.py, module as we did for homework 4. You will need to have this file in the same folder as your solution. Here is the starter code for this assignment. Your program will produce the image below containing these drawings. A question you need to answer is how much space is between each line so that the total height equals the width. For example, look at Figure 2. The width is 200 so the total height should also be 200. There are 5 lines, with 4 areas of space between them. How much space goes between each line? It's not 200/5, or 40. If there are 4 areas of space, with a height of 40 in each, that's only 40 * 4, or 160 units. HW6 Lines Here are the properties of Figures 1, 2, 3: Figure 1 Description Width Top left endpoint (x, y) Number of lines Color Figure 1 120 (-200, 300) 20 brown Figure 2 Figure 2 200 (135, 200) 5 purple Figure 3 90 (-300, -280) 8 red Figure A Now, look at Figures A, B, and C. I will refer to each of these as one fan. A fan is made up of straight lines that all share a common endpoint. The common endpoint actually represents the center of a square. The width of the fan is the width(and height) of that square. Figure B A fan either points up or down. . Given the coordinates of the common point and the width, you can calculate the other endpoint of the furthest left line. That end point is at a corner of the square. . Successive lines are drawn with shifted endpoints. The amount of space between each end point is based on the width and number of lines. The calculated endpoints follow along a horizontal path (either the top or bottom of the square). A question you need to answer is how much space is between each end point so that the width of the overall shape equals the width specified. For example, look at Figure C. The width 150. There are 5 lines, with 4 areas of space between them. How much space goes between each line so that the total width is 150? It's not 150/5, or 30. If there are 4 areas of space, with a width of 30 in each, that's only 30 * 4, or 120 units. Here are the properties of each row of fan: Figure C Figure 3 Number of lines Color Facing Up Your program will not display any of the text (like the words Figure 1 or Figure C). I've added those to help this discussion. 10 Common Description Width point (x,y) Figure A 120 (0,0) Figure B 200 (-350, 0) file:///C:/Users/merid/Desktop/CSC110 - HW6.html blue orange True False 10 file:///C:/Users/merid/Desktop/CSC110 - HW6.html 1/5 2/5 21182021 CSC110 - HWS Figure 150 (200, -200) CSC110 - HWE green s | False 2118/2021 14 - comments, style 12 - report Implementation Requirements Good Luck! Extra Credit (2 points) Here's an update image with 2 rows of fans added. HWB unes You need to implement two function definitions, 1. one function to draw one line grid at any location, of any width, with any number of lines, and any color 2. one function to draw one fan at any location, of any width, with any number of lines, and any color, and facing up or down. Do not write 2 functions for the fan, one to draw facing up and the other to draw facing down. There should be just 1 function to draw a fan, with a parameter specifying facing up or down. Other than some difference in math, the algorithm is the same regardless of facing up or down. Put 6 function calls in your main() function to create the image above, using the values from the tables as arguments. Note - when I calculated the amount of space between the lines, I used math.floor() to get an integer value. Documentation and Style Please follow the Documentation and Style Guidelines found on the class website. Suggestions I recommend starting by drawing a line grid and a fan on graph paper using the one of the examples. Using specific values from the example you will see how to calculate the end points and the amount of space between lines. Implement one function at a time, and testing as you go. Testing should include calling your function several times, with different arguments, to ensure that the function uses the parameter values correctly. 1 Written Report Please type up the answers to the following questions and include it at the bottom of your .py file: 1. How did you go about starting this assignment? Where did you get stuck, if at all, and how did you get unstuck? 2. How did you test your program? Does your program meet the homework specification? What doesn't work as you'd like? 3. What did you learn from this assignment? What would you do differently on the next project? Grading The first new row, near the top, has 5 red fans, which alternate facing up, down, up, down, up. The second row, near the bottom, has 8 purple fans. Write a new function that will display a row of alternating fans. The left-most fan in the row is always facing up. The parameters are 16 - line grid function definition 16- fan function definition 12 - main() definition file:CUsers meridesktop CSC110 - HW. the width of 1 fan 315 fleusesimerd Desktop CSC110 - HWS. 415 CSC110 - HWS 2118/2021 the common point for the left-most fan the number of lines per fan the number of fans the color Here is the data used in the calls to make the updated image Description Width Common point (x,y) Number of lines Number of fans Color red row 140 (-350, 310) 15 red purple row 100 (-400, -165) purple # Starter code for homework 6 CANVAS_WIDTH = 900 CANVAS_HEIGHT = 800 from Gui import def main(): # remove these lines and add your own code canvas.text([0,0], text = "hello") canvas.line ([[-20,0], [-100, 0]], fill = 'red') ### ########### # Feel free to read what's here, but do not change g = Gui() g.title('HW6 Lines') # canvas is the drawing area canvas = g.ca(width = CANVAS_WIDTH, height = CANVAS_HEIGHT) main() g.mainloop() 2/18/2021 CSC110 - HWE 2/18/2021 CSC110 - HWE Look at Figures 1, 2, and 3. I will refer to each of these as one line grid Drawings Objectives Working with loops Continued practice with functions definitions and if statements Each line grid is made up of a sequence of straight lines. . Given the coordinates of the top line left endpoint and the width, you should be able to figure out the coordinates of the right endpoint of that top line. Successive lines are drawn with shifted endpoints. The amount of space between each horizontal line is based on the width and number of lines. Each grid should have the same height as its width. For this assignment you'll be using the Gui.py, module as we did for homework 4. You will need to have this file in the same folder as your solution. Here is the starter code for this assignment. Your program will produce the image below containing these drawings. A question you need to answer is how much space is between each line so that the total height equals the width. For example, look at Figure 2. The width is 200 so the total height should also be 200. There are 5 lines, with 4 areas of space between them. How much space goes between each line? It's not 200/5, or 40. If there are 4 areas of space, with a height of 40 in each, that's only 40 * 4, or 160 units. HW6 Lines Here are the properties of Figures 1, 2, 3: Figure 1 Description Width Top left endpoint (x, y) Number of lines Color Figure 1 120 (-200, 300) 20 brown Figure 2 Figure 2 200 (135, 200) 5 purple Figure 3 90 (-300, -280) 8 red Figure A Now, look at Figures A, B, and C. I will refer to each of these as one fan. A fan is made up of straight lines that all share a common endpoint. The common endpoint actually represents the center of a square. The width of the fan is the width(and height) of that square. Figure B A fan either points up or down. . Given the coordinates of the common point and the width, you can calculate the other endpoint of the furthest left line. That end point is at a corner of the square. . Successive lines are drawn with shifted endpoints. The amount of space between each end point is based on the width and number of lines. The calculated endpoints follow along a horizontal path (either the top or bottom of the square). A question you need to answer is how much space is between each end point so that the width of the overall shape equals the width specified. For example, look at Figure C. The width 150. There are 5 lines, with 4 areas of space between them. How much space goes between each line so that the total width is 150? It's not 150/5, or 30. If there are 4 areas of space, with a width of 30 in each, that's only 30 * 4, or 120 units. Here are the properties of each row of fan: Figure C Figure 3 Number of lines Color Facing Up Your program will not display any of the text (like the words Figure 1 or Figure C). I've added those to help this discussion. 10 Common Description Width point (x,y) Figure A 120 (0,0) Figure B 200 (-350, 0) file:///C:/Users/merid/Desktop/CSC110 - HW6.html blue orange True False 10 file:///C:/Users/merid/Desktop/CSC110 - HW6.html 1/5 2/5 21182021 CSC110 - HWS Figure 150 (200, -200) CSC110 - HWE green s | False 2118/2021 14 - comments, style 12 - report Implementation Requirements Good Luck! Extra Credit (2 points) Here's an update image with 2 rows of fans added. HWB unes You need to implement two function definitions, 1. one function to draw one line grid at any location, of any width, with any number of lines, and any color 2. one function to draw one fan at any location, of any width, with any number of lines, and any color, and facing up or down. Do not write 2 functions for the fan, one to draw facing up and the other to draw facing down. There should be just 1 function to draw a fan, with a parameter specifying facing up or down. Other than some difference in math, the algorithm is the same regardless of facing up or down. Put 6 function calls in your main() function to create the image above, using the values from the tables as arguments. Note - when I calculated the amount of space between the lines, I used math.floor() to get an integer value. Documentation and Style Please follow the Documentation and Style Guidelines found on the class website. Suggestions I recommend starting by drawing a line grid and a fan on graph paper using the one of the examples. Using specific values from the example you will see how to calculate the end points and the amount of space between lines. Implement one function at a time, and testing as you go. Testing should include calling your function several times, with different arguments, to ensure that the function uses the parameter values correctly. 1 Written Report Please type up the answers to the following questions and include it at the bottom of your .py file: 1. How did you go about starting this assignment? Where did you get stuck, if at all, and how did you get unstuck? 2. How did you test your program? Does your program meet the homework specification? What doesn't work as you'd like? 3. What did you learn from this assignment? What would you do differently on the next project? Grading The first new row, near the top, has 5 red fans, which alternate facing up, down, up, down, up. The second row, near the bottom, has 8 purple fans. Write a new function that will display a row of alternating fans. The left-most fan in the row is always facing up. The parameters are 16 - line grid function definition 16- fan function definition 12 - main() definition file:CUsers meridesktop CSC110 - HW. the width of 1 fan 315 fleusesimerd Desktop CSC110 - HWS. 415 CSC110 - HWS 2118/2021 the common point for the left-most fan the number of lines per fan the number of fans the color Here is the data used in the calls to make the updated image Description Width Common point (x,y) Number of lines Number of fans Color red row 140 (-350, 310) 15 red purple row 100 (-400, -165) purple # Starter code for homework 6 CANVAS_WIDTH = 900 CANVAS_HEIGHT = 800 from Gui import def main(): # remove these lines and add your own code canvas.text([0,0], text = "hello") canvas.line ([[-20,0], [-100, 0]], fill = 'red') ### ########### # Feel free to read what's here, but do not change g = Gui() g.title('HW6 Lines') # canvas is the drawing area canvas = g.ca(width = CANVAS_WIDTH, height = CANVAS_HEIGHT) main() g.mainloop()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions