So I have this assignment I have been working on for a class, but having trouble trying to duplicate the shapes within the boundaries I have set. The code is below for what I already have and a picture for what I need. I have the circles and shapes down, but just need a little insight on how to repeat them on the second row like the picture. Any help would be the best!!!

WHAT I NEED:
Name:  assignment.jpg
Views: 108
Size:  60.5 KB


WHAT I HAVE:


import java.awt.*;

public class Illusion {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel (500, 400);
panel.setBackground(Color.GRAY);
Graphics g = panel.getGraphics();
drawBasic(g, 0, 0, 3, 90);
drawBasic(g, 120, 10, 3, 90);
drawBasic(g, 250, 50, 5, 90);
drawGrid(g, 10, 120, 10, 100, 2);
drawGrid(g, 350, 20, 5, 40, 3);
drawGrid(g, 230, 160, 5, 50, 4);

}
public static void drawBasic(Graphics g, int x, int y,
int circles, int size) {
int gap=size/(2*circles);
g.setColor(Color.RED);
g.fillOval(x, y, size, size);
g.setColor(Color.BLACK);
for (int i=0; i<circles; i++) {
g.drawOval(x+(i*gap), y+(i*gap), size-(2*i*gap), size-(2*i*gap));
}

Polygon diamond = new Polygon();
diamond.addPoint(x+(size/2), y);
diamond.addPoint(x, y+(size/2));
diamond.addPoint(x+(size/2), y+size);
diamond.addPoint(x+size, y+(size/2));
g.drawPolygon(diamond);

}
public static void drawGrid(Graphics g, int x, int y, int circles, int size, int rows){
g.setColor(Color.LIGHT_GRAY);
g.fillRect(x, y, size*rows, size*rows);
g.setColor(Color.RED);
g.drawRect(x, y, size*rows, size*rows);
for(int i=0; i<rows; i++) {
drawBasic(g, x+(i*size), y, circles, size);

}

}

}