Graphics practice

posted by: Ms. Martin 11 October 2010 No Comment

These practice problems are designed to get you working with basic graphics.  You will not be turning these in or getting checked off — they’re just for you to practice!!  Feel free to skip around and experiment.

You will write a program to produce the following figure:

The DrawingPanel has size 300 x 250 and has a yellow background.  You should put each problem in a separate method.  To have multiple methods draw to the same DrawingPanel object, pass the Graphics object to each of them.  That way, they will use the same pen to draw.

  1. Draw a bear face.  The face and ears are orange.  The face starts at 50, 50 and is a circle with a diameter of 50.  The ears have a diameter of 20 and start at (45, 50) and (85, 50).  The eyes are black circles with a diameter of 5.  They are each 10 pixels in from the edge of the face’s bounding rectangle.  The mouth is a rectangle of size 10 x 3 starting at (70, 85).
  2. Draw squares using a for loop.  The smallest square has size 20 x 20.  Each of the next squares is 20 pixels bigger than the last.  The diagonal line starts at (150, 50).
  3. Draw a target.  The largest circle is red and starts at (20, 120).  Each subsequent circle is 10 pixels smaller in diameter.  Colors alternate between red and white.
1 Star2 Stars3 Stars4 Stars5 Stars (16 votes, average: 2.81 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>