Putting it all together

What if we wanted to have two object rotating on the screen at different rates? Since the translate() and rotate() functions are cumulative, we could try to make a transformation for one object and then make another transformation relative the first, but that seems like an awful lot of math. It might just be easier to make them operate independently.

push() pop()

The push() function saves the current drawing style settings and transformations, while pop() restores these settings. Note that these functions are always used together. They allow you to change the style and transformation settings and later return to what you had. When a new state is started with push(), it builds on the current style and transform information. The push() and pop() functions can be embedded to provide more control.

Video Explanation

Video Explanation

Comprehension Check

Assignment

In Groups: Create a watch face that can accurately display time in digital and analog, i.e. with hour, minute, and second hands.

Your code must include:

  • All header information
  • Comments
  • A clock face with analog hands for seconds, minutes, and hours
  • A digital readout of the time.
  • BONUS Display ticks around the outside of the watch face (2pts)
  • BONUS Creativity and style 1 - 5 extra points. Try researching existing watch faces and creating a reproduction of what you find.

In order to get the current hour, minute, and second based on your computer’s clock use the following:

  • hour();
  • minute();
  • second();

Previous section: