logo CodeStepByStep logo

circles

Language/Type: Python graphics functions parameters DrawingPanel
Related Links:

Write a complete program that draws the following graphical figure onto a DrawingPanel:

Java DrawingPanel close maximize minimize
expected output
 

The overall drawing panel is size 500 x 350. Its background is cyan. The rectangular area behind the grids is green, and the background of the circles is yellow. The rectangles and circles are outlined in black. Each grid also has a pair of lines drawn across it in an "X" pattern.

The seven figures on the panel should have the following properties:

Description (x, y) position size of subfigure circles per subfigure rows/cols
top-left (0, 0) 100 x 100 10 N/A
top-middle 1 (130, 25) 100 x 100 10 N/A
top-middle 2 (260, 0) 60 x 60 6 N/A
top-right (360, 50) 80 x 80 4 N/A
bottom-left (10, 170) 48 x 48 4 3 x 3
bottom-middle (180, 200) 24 x 24 2 5 x 5
bottom-right (330, 170) 72 x 72 9 2 x 2

Structure your solution and eliminate redundancy using functions. Write a function to draw one single concentric circle subfigure. A subfigure is one set of yellow and black concentric circles. Different subfigures have different sizes, positions, and so on. Therefore, your function should accept several parameters so that it is possible to call it many times to draw the many different subfigures on the screen. Assume that every subfigure's width and height are the same, and that the subfigure's size is a multiple of its number of circles, so that all coordinates are integers.

Write another function that produces a square grid of subfigures. You will call this function three different times to produce the grids of the overall figure. It will need a lot of parameters to be flexible enough to draw each of these grids. The key point is that this single function can be called multiple times to produce all the grids in the overall figure. Your two functions should work together to remove redundancy. Assume each grid has an equal number of rows and columns.

Complete program: Write an entire program that you could put into a file and run outside of CodeStepByStep.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.