// CSE 142 Lecture 6 // More Parameters, Graphics import java.awt.*; // for Graphics and Color // We didn't actually talk about this in lecture. // Somebody asked me at the end of class if it was possible to // draw a circle where each quarter of the circle was a different // color. The answer is yes, Graphics has a fillArc method. public class QuarterCircle { public static final int TOP_LEFT = 25; public static final int WIDTH_HEIGHT = 150; public static final int QUARTER = 90; public static void main(String[] args) { DrawingPanel p = new DrawingPanel(200, 200); Graphics g = p.getGraphics(); g.setColor(Color.GREEN); drawQuarter(g, 45); g.setColor(Color.RED); drawQuarter(g, 135); g.setColor(Color.BLUE); drawQuarter(g, 225); g.setColor(Color.ORANGE); drawQuarter(g, 315); } // Draws a quarter of a circle starting at startAngle and proceeding // counter-clockwise. public static void drawQuarter(Graphics g, int startAngle) { g.fillArc(TOP_LEFT, TOP_LEFT, WIDTH_HEIGHT, WIDTH_HEIGHT, startAngle, QUARTER); } }