CS 51580 - Homework 1 CS 51580 Syllabus Lectures and Readings Homework Assignments Roger Kraft Computer Science Department School of Engineering College of Engineering & Sciences Purdue University Northwest Programming Assignment 1 CS 51580 Computer Graphics Spring, 2022 This assignment makes use of the files contained in this zip file. This assignment is due Wednesday, February 2. This assignment is about using the Java graphics library to draw pixels in a panel. In the zip file there is a file Hw1_Panel.java that you need to complete. When Hw1_Panel.java is done, then the file Hw1.java will instantiate the panel and draw a picture like the four example pictures, Hw1_example_1.png through Hw1_example_4.png, in the zip file. Your Hw1_Panel.java should draw non-overlapping circles in the panel. The number of circles is a parameter to the Hw1_Panel constructor. The circles should be placed randomly in the panel. Each time the panel is instantiated, it should generate a random list of circle centers and radii. The circles should not overlap each other. The circles can extend over the left and right edges of the panel, but the circles cannot extend over the top and bottom edges. The easiest way to get all the non-overlapping circles is to generate a circle's center and radius, then check if it overlaps any previously generated circle (or extends over the top or bottom edges). If it does, discard the circle and generate another. Keep doing this until you have the required number of circles. (This can end up taking a very long time if you try to generate too many non-overlapping circles.) Remember that two circles overlap if the distance between their centers is less than the sum of their radii. Draw the circles with a 6 pixel wide circumference. The Java Graphics class does not have the ability to draw circles with different thickness. You can get this effect by drawing two filled circles. Draw two concentric filled-in circles with different radii and different colors. The band between the two circumferences will be your thickened circle (so the two concentric circles should have radii that differ by 6). The area outside the circles is a checkerboard pattern. You need to figure out a way to draw this pattern. There are many ways in which this can be done. Draw this pattern first, before you draw the circles (on top of this pattern). You need to duplicate the exact color values used in the example images, Hw1_example_1.png through Hw1_example_4.png. Use a utility program like the (freeware) ColorMania color picker (portable version). The area inside the circles is an interesting pattern created by bitwise-ORing the coordinates of each pixel. In the zip file there is a program Hw1_background.java that demonstrates how this pattern is created. In the file Hw1_Panel.java you need to write the constructor and the paintComponent() method. The constructor should compute the centers and radii of the non-overlapping circles and store those values for use by the paintComponent() method. The paintComponent() method should use those stored values to draw the circles. The paintComponent() method should not calculate the circles. If it did, then every time the panel is redrawn by the GUI system, the panel would compute new, different, circles. In order to have the panel redraw the same circles, the circles need to be computed one time. So the constructor is the right place in which to do this. Here is a list of classes and methods that you might use. Graphics class setColor() drawLine() drawOval() fillOval() drawRect() fillRect() Color class Color(int,int,int) constructor Random class nextInt(int bound) Turn in a zip file called CS51580w1Surname.zip (where Surname is your last name) containing just your version of Hw1_Panel.java. This assignment is due Wednesday, February 2. compliments and criticisms