public void run() { getWidth(); getHeight(); double x = getWidth() / 2; double y = getHeight() / 2; GRect a = new GRect(x - 1.5 * SIZE, y - 1.5 * SIZE, SIZE, 3 * SIZE); a.setColor(Color.RED); a.setFilled(true); add(a); GRect b = new GRect(x - SIZE / 2, y - 1.5 * SIZE, SIZE, 3 * SIZE); b.setColor(Color.YELLOW); b.setFilled(true); add(b); GRect c = new GRect(x + SIZE / 2, y - 1.5 * SIZE, SIZE, 3 * SIZE); c.setColor(TURQUOISE); c.setFilled(true); add(c); GLabel d = new GLabel("Flag of Peru", x + SIZE, y + 1.9 * SIZE); d.setColor(Color.BLACK); d.setFont("Broadway-12"); add(d); }
private void colorBrick(int row, GRect brick) { if (row < 2) { brick.setColor(Color.RED); } else if (row < 4) { brick.setColor(Color.ORANGE); } else if (row < 6) { brick.setColor(Color.YELLOW); } else if (row < 8) { brick.setColor(Color.GREEN); } else if (row < 10) { brick.setColor(Color.CYAN); } }
/** The method takes parameters and returns, square shape figure */ private GRect rectangle(int x, int y, int width, int height, Color colorSetFill, Color colorSet) { GRect rectangle = new GRect(x, y, width, height); rectangle.setFilled(true); rectangle.setFillColor(colorSetFill); rectangle.setColor(colorSet); add(rectangle); return rectangle; }
private void buildMouth() { double startingWidth = getWidth() / 2 - mouth_width / 2; double startingHeight = getHeight() / 2 + head_height / 4 - mouth_height / 2; GRect mouth = new GRect(startingWidth, startingHeight, mouth_width, mouth_height); add(mouth); mouth.setColor(Color.WHITE); mouth.setFilled(true); mouth.setFillColor(Color.WHITE); }
private void PaintRect(int xPosition, int yPosition) { // Paint square, white color GRect rect = new GRect((xPosition / 2), (yPosition / 2), 2 * xPosition, 2 * yPosition); rect.setFilled(true); rect.setColor(Color.WHITE); add(rect); }
/** Places a rectangle at x,y with width, height and specified color */ public void place(int x, int y, int width, int height, Color shapeColor) { GRect shape = new GRect(x, y, width, height); shape.setFilled(true); shape.setColor(shapeColor); add(shape); }