Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. /**
  8. *
  9. * @author illcod
  10. */
  11. import java.awt.*;
  12. import java.applet.*;
  13. public class Snowman extends Applet {
  14. public void paint (Graphics g) {
  15. final int MID = 150;
  16. final int TOP = 50;
  17.  
  18. setBackground(Color.cyan);
  19.  
  20. // fill a blue rectangle on the screen to make the ground
  21. g.setColor(Color.blue);
  22. g.fillRect(0,175,300,50);
  23.  
  24. // fill a yellow oval (circle) in the sky to make the sun
  25. g.setColor(Color.yellow);
  26. g.fillOval(-40,-40,80,80);
  27.  
  28. // fill in the snowman parts
  29. g.setColor(Color.white);
  30. g.fillOval(MID-20,TOP,40,40); //head
  31. g.fillOval(MID-35,TOP+35,70,50); //upper torso
  32. g.fillOval(MID-50,TOP+80,100,60); //lower torso
  33.  
  34. // buttons on front
  35. g.setColor(Color.black);
  36. g.fillOval(MID-3,TOP+50,5,5);
  37. g.fillOval(MID-3,TOP+60,5,5);
  38. g.fillOval(MID-3,TOP+70,5,5);
  39.  
  40. //draw the eyes
  41. g.setColor(Color.black);
  42. g.fillOval(MID-10,TOP+10,5,5);
  43. g.fillOval(MID+5,TOP+10,5,5);
  44.  
  45. g.drawArc (MID-10,TOP+20,20,10,190,160); //smile
  46.  
  47. g.drawLine (MID-25,TOP+60,MID-60,TOP+40); //left arm
  48. g.drawLine (MID+25,TOP+60,MID+55,TOP+60); //right arm
  49.  
  50. g.setColor(Color.GRAY);
  51. g.drawLine(MID-20,TOP+5,MID+20,TOP+5); //brim of hat
  52. g.fillRect(MID-15,TOP-20,30,25); //top of hat
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement