Question: # This function paints a bunch of black lines radially around where R1 and R2 are the inner and outer radii and Segments indicates the

# This function paints a bunch of black lines radially around where R1 and R2 are the inner and outer radii and Segments indicates the number of lines. Xc, Yc, R1, and R2 are all allowed to be floats. #

def addStarburst (Canvas,Xc,Yc,R1,R2,Segments):

return

In the blank space in the addStarburst function (see above), write new code to plot a bunch of radial lines around the center . The number of lines is in parameter Segments, and is always a positive integer. For each line, you need to compute its angle as a fraction of the distance around a circle, which is 2 pi radians. That is, the increment (how much the angle changes between any two lines) is computed by dividing 2 pi by the number of segments. Start with the angle equal to 0, and for each new line add the increment to the old angle to compute the new angle. Once you know the angle for a particular line, its endpoints can be computed with a little trigonometry:

X1 = Xc + R1 cos(angle)

Y1 = Yc R1 sin(angle)

X2 = Xc + R2 cos(angle)

Y2 = Yc R2 sin(angle)

Use the addLine function from JES to draw a line between and . Be careful about the data types of your numbers: the coordinates are floats, but addLine expects integers.

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 Databases Questions!