Question: Using the drawing panel we used in class (DrawingPanel.java ), draw house. JAVA, modify the below program to animate the clouds and chimney smoke. the
Using the drawing panel we used in class (DrawingPanel.java
), draw house.
JAVA, modify the below program to animate the clouds and chimney smoke. the clouds should be moving right and smoking moving up
import java.awt.*;
public class House {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(750, 500); panel.setBackground (new Color(65,105,225)); Graphics g = panel.getGraphics(); background(g); house (g); houseRoof (g); garageRoof (g); windows (g); windowsframes (g); chimney(g); lawn (g); } /** * * @param g */ static public void background(Graphics g) { g.setColor (new Color (225,225,225));//clouds g.fillOval (14,37,170,55); g.fillOval (21,21,160,50); g.fillOval (351,51,170,55); g.fillOval (356,36,160,50); }
static public void house (Graphics g) { g.setColor (new Color(139,69,19)); //house g.fillRect (100,250,400,200); g.fillRect (499,320,200,130); g.setColor(new Color(190,190,190)); //chimney and doors g.fillRect (160,150,60,90); g.fillRect (245,380,110,70); g.fillRect (508,350,180,100); g.setColor (new Color(186,134,11)); //door handle g.fillOval (282,412,10,10); g.fillOval (307,412,10,10);
}
static public void houseRoof (Graphics g) { g.setColor(new Color(190,190,190)); //house roof int x[] = {98,300,501}; int y[] = {250,130,250}; g.fillPolygon(x,y,3); }
static public void garageRoof (Graphics g) { g.setColor (new Color(190,190,190)); //garage roof int x[] = {499,499,700}; int y[] = {320,249,320}; g.fillPolygon(x,y,3); }
static public void windows (Graphics g) { g.setColor (Color.orange); //windows outer frame effect g.fillOval (521,350,68,31); g.fillOval (606,350,68,31); g.fillRect (121,261,78,78); g.fillRect (401,261,78,78); g.setColor (Color.white); //windows with frames g.fillRect (125,265,70,70); g.fillRect (405,265,70,70); }
static public void windowsframes (Graphics g) { g.setColor (new Color(139,69,19)); // door sections g.fillRect (299,380,2,70); g.fillRect (507,382,180,2); g.fillRect (507,417,180,2); g.setColor (new Color(186,134,11)); //inner frame effect g.fillRect (156,265,5,70); g.fillRect (436,265,5,70); g.fillRect (124,298,70,5); g.fillRect (404,298,70,5); g.fillRect (244,375,110,5); //door frame g.fillRect (241,375,5,75); g.fillRect (354,375,5,75); g.fillRect (508,345,180,5); g.fillRect (505,345,5,105); g.fillRect (684,345,5,105); }
static public void chimney (Graphics g) { g.setColor (new Color(210,180,140)); //smoke for chimney g.fillOval (162,106,36,44); g.fillOval (172,96,36,44); g.fillOval (162,86,36,44); g.fillOval (172,36,36,44); g.fillOval (162,26,36,44); g.fillOval (172,16,36,44);
} static public void lawn (Graphics g) { g.setColor (new Color(19,69,19)); //lawn g.fillRect (100,453,405,500); }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
