Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# 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

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

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions