//Natasha Marshall //forest.java import java.awt.*; import ohjava.*; public class marshall { private static Graphics g; public static void main(String args[]) { DrawableFrame df; df = new DrawableFrame("The Forest"); df.show(); df.setSize(800, 600); g = df.getGraphicsContext(); drawRainbow(640, 160, 100, 5); drawSun(140, 60, 50); drawRainbow(340, 180, 50, 5); drawTree(200,200,20,80,80,80); drawTree(300,200,20,80,80,80); drawTree(400,200,20,80,80,80); drawTree(500,200,20,80,80,80); drawTree(600,200,20,80,80,80); df.repaint(); } private static void drawSun(int x, int y, int r) { int x1, y1, width, height; Color c; c = Color.yellow; x1 = x - r; y1 = y - r; width = 2 * r; height = 2 * r; g.setColor(c); g.fillOval(x1, y1, width, height); } private static void drawTree(int m, int n, int w1, int h1, int w2, int h2) { int x[], y[], n1, n2, n3, m1, m2, m3; Color c, b; x = new int[3]; y = new int[3]; c = Color.green; b = new Color(128, 0, 0); m1 = m + (w2 / 2); n1 = n + h2; m2 = m + w2; n2 = n + (2 * h2); m3 = m + (w2-w1)/2; n3 = n + (3 * h2); g.setColor(c); x[0] = m2; y[0] = n1; x[1] = m; y[1] = n1; x[2] = m1; y[2] = n; g.fillPolygon(x, y, 3); g.setColor(c); x[0] = m2; y[0] = n2; x[1] = m; y[1] = n2; x[2] = m1; y[2] = n1; g.fillPolygon(x, y, 3); g.setColor(c); x[0] = m2; y[0] = n3; x[1] = m; y[1] = n3; x[2] = m1; y[2] = n2; g.fillPolygon(x, y, 3); g.setColor(b); g.fillRect(m3, n3, w1, h1); } private static void drawRainbow(int x, int y, int r, int d) { int x1, x2, x3, x4, x5, x6, x7, y1, y2, y3, y4, y5, y6, y7; int w1, w2, w3, w4, w5, w6, w7, h1, h2, h3, h4, h5, h6, h7; x1 = x - r; y1 = y - r; x2 = x1 - d; y2 = y1 - d; x3 = x2 - d; y3 = y2 - d; x4 = x3 - d; y4 = y3 - d; x5 = x4 - d; y5 = y4 - d; x6 = x5 - d; y6 = y5 - d; x7 = x6 - d; y7 = y6 - d; w1 = 2 * r; h1 = 2 * r; w2 = w1 + 2 * d; h2 = h1 + 2 * d; w3 = w2 + 2 * d; h3 = h2 + 2 * d; w4 = w3 + 2 * d; h4 = h3 + 2 * d; w5 = w4 + 2 * d; h5 = h4 + 2 * d; w6 = w5 + 2 * d; h6 = h5 + 2 * d; w7 = w6 + 2 * d; h7 = h6 + 2 * d; g.setColor(Color.red); g.drawArc(x7, y7, w7, h7, 0, 180); g.setColor(Color.blue); g.drawArc(x6, y6, w6, h6, 0, 180); g.setColor(Color.green); g.drawArc(x5, y5, w5, h5, 0, 180); g.setColor(Color.pink); g.drawArc(x4, y4, w4, h4, 0, 180); g.setColor(Color.gray); g.drawArc(x3, y3, w3, h3, 0, 180); g.setColor(Color.magenta); g.drawArc(x2, y2, w2, h2, 0, 180); g.setColor(Color.orange); g.drawArc(x1, y1, w1, h1, 0, 180); } }