pair programming assignment

Graphics Lab 2

Note

This week's Learning Exercises

  1. RobotWorld

    Use the graphics commands to draw an empty RobotWorld. You only have to draw the 15 * 15 cells. I.e. not the short information windows at the top and the bottom, or the coordinates. Here's a hint.

  2. Coloured Circles

    Write a program that draws a circle on the screen and waits for the user to press the mouse button. If the mouse is pressed inside the circle, then change the colour of the circle to green. Otherwise change the colour of the circle to red.

    Hint: look at the isPressed() and getMouse() methods.

    For extra credit, place the whole program in a while loop, so that it continuously awaits mouse presses and operates accordingly.

    Hint: to determine if a point is in a circle, you can use this hint

  3. Coloured Line

    Draw a line that varies in colour along its length. It should start out as red and gradually transform to blue. Here is some Colour info.

  4. Optional Exercise

    A small change is required to get the previous program to draw a rectangle that varies gradually in colour from left to right. Try and change the colours so they go from

    Can you get the colour of the rectangle to change as it goes down (rather than across).