COMP4033 Assignment 1 - Basic Computer Graphics (5%)
Due: 11:59pm, 13 March 2021
Complete the following two exercises by writing a Java program for each:
1. Draw a set of concentric pairs of squares, each consisting of a square with horizontal and vertical edges
and one rotated through 45°. Except for the outermost square, the vertices of each square are the
midpoints of the edges of its immediately surrounding square, as Figure 1 shows. It is required that all
lines are exactly straight, and that vertices of smaller squares lie exactly on the edges of larger ones.
Figure 1. Concentric squares
2. Write a program that draws a pattern of hexagons, as shown in Figure 2. The vertices of a (regular)
hexagon lie on its so-called circumscribed circle. The user must be able to specify the radius of this circle
by clicking a point near the upper-left corner of the drawing rectangle. Then the distance between that
point and that corner is to be used as the radius of the circle just mentioned. There must be as many
hexagons of the specified size as possible and the margins on the left and the right must be equal. The
same applies to the upper and lower margins, as Figure 2 shows.
Note: you should try to minimize the number of lines that are drawn more than once. You can see the
repeated lines by using a different foreground color for each round of drawing, or better, by using the
XOR writing mode with the foreground color being black (if you know how to use XOR mode).
Figure 2. Hexagons
Put the 2 Java source programs in a ZIP file and name it as “Ass1_1234567890" (replace
1234567890 with your student ID number). Submit your ZIP file through iSpace before the due
time. Late submissions will NOT be accepted.
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。