In: Computer Science
Write a program named MyHometown_Icon.java. The program will be an application (i.e have a main method). It will be in the default package. It will import edu.wiu.StdDraw. Its main method will make calls to methods in StdDraw to draw something iconic about your hometown.
Multiple colors should be used.Multiple primitive types will be used and the drawing will consists of more than 20 primitive shapes.
import edu.wiu.StdDraw;
public class MyHometown_icon
{
public static void main(String args[])
{
stdDraw.setCanvas(500,500); //Set window size 500 pixel by 500
stdDraw.Clear(stdDraw.BLUE);//Set blue colour of sky
//draw green field
stdDraw.setPenColor(0,170,0);
stdDraw.filledRectangle(0.5,0.25,0.6,0.3);
//draw circular cloud at the mouse location as long as mouse is within bounds
while(true)
{
double cloudX=stdDraw.mouseX();
double cloudY=stdDraw.mouseY();
StdDraw.PenColor(StdDraw.WHITE);
if(cloudY>0.55)
{
stdDraw.filledCircle(cloudX,cloudY,0.005);
}
StdDraw.show(30);
}
// draw a blue diamond, radius 0.1 (old method) StdDraw.setPenRadius(); // default radius StdDraw.setPenColor(Colors.BOOK_BLUE); double[] x = {.1, .2, .3, .2}; double[] y = {.2, .3, .2, .1}; StdDraw.filledPolygon(x, y); // draw a cyandiamond, radius 0.1 (new method) StdDraw.setPenColor(Colors.CYAN); StdDraw.filledDiamond(.45, .2, 0.1); // draw a magenta triangle, radius 0.1 StdDraw.setPenColor(Colors.MAGENTA); StdDraw.filledTriangle(.45, 0.4, 0.1);
// Draw filled Square StdDraw.setPenColor(StdDraw.BLUE); StdDraw.filledSquare(5, 8, 2); // Draw Circle StdDraw.setPenColor(StdDraw.BLACK); StdDraw.setPenRadius(); StdDraw.circle(5, 5, 2);
}
}