This program is to illustrate basic graphics functions that you need to know.

See the template program in the pdf folder in the HSA2_master folder.

Do the following

  1. Make a window/console that is 800x600
  2. Set the title of your graphics window to something else (e.g "Graphics 2")
  3. make a new colour and assign it to a variable "Color lightBrown = ..."
  4. set a background colour.
    Note: you have to do this before you draw any other graphics. gc.clear() must also be run for it to work.
  5. Draw diagonal lines from one corner to the other
    Note: if needed, use c.getDrawWidth() to find the width of the drawing area.
  6. Draw horizontal lines that cut the screen in half vertically and horizontally
    You should try and do this without using the numbers for the width and height, so that if you make the console with a size of 1080x 768 or anything else the lines will still be in the right place. Test it by actually changing the size of your graphics console and see if the lines are still in the correct places.
  7. turn on antiAliasing
    The rest of this stuff can be drawn anywhere on the screen ◀
    It does not have to have the same colours and locations as in the example
  8. draw an empty circle
  9. draw a filled in circle and make a different colour outline around the circle
  10. draw something with a thicker line (using setStroke)
  11. write text (using drawString) with the default font and then with a new font
  12. draw a coloured rectangle
  13. make a semitransparent colour
  14. draw a second colour rectangle that partially overlaps the first rectangle.

Extra: now change the size of your graphics console to 1080 by 768 and see if the lines still go to the corners.


Other

You can center your graphics window by typeing gc.setLocationRelativeTo(null); as the first line in your program.

Example