import java.awt.*; // Imports art utils
import javax.swing.*; //Imports program used to show graphics
public class Penguin extends Canvas // Class name and allows class to be used elsewhere
{
public static void main (String [] args) //Main method
{
JFrame frame = new JFrame("Penguin"); //Creates a new JFrame (method used to display code)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Makes the code exit when the exit button is pressed
Canvas canvas = new Penguin(); //Creates new canvas
canvas.setSize(600, 600); //Sets canvas size
canvas.setBackground(Color.cyan);//Sets canvas background
frame.add(canvas);// Adds canvas to frame to show
frame.pack();
frame.setVisible(true); //Allows canvas to show
}
public void paint(Graphics g) //Method used to create the graphics
{
//All declerations made here store a color in a variable through RGB values
Color e = new Color ( 0,0,0);
Color f = new Color ( 255, 153, 0);
Color i = new Color ( 217, 217, 217);
Color h = new Color ( 255, 255, 255);
g.setColor (e); //Creates the penguins body
g.fillOval (90,142, 400,400);
g.setColor (i); //Adds the penguins stomach and shadow
g.fillOval (137,275, 305,260);
g.setColor (h);
g.fillOval (165,275, 250,250);
//Makes penguins feet
g.setColor (f);
g.fillOval (307,490, 190,75);
g.setColor (f);
g.fillOval (90,490, 190,75);
g.setColor (h); //Makes penguins eyes
g.fillOval (190,152, 105,120); //Left eye
g.setColor (h);
g.fillOval (300,173, 135,100); //Right eye
g.setColor (e);//Makes penguins pupils
g.fillOval (304,205, 30,40);//Left pupil
g.setColor (e);
g.fillOval (245,190, 50,60); //Right pupil
}//End of paint
}