CS108 Lab 2: Drawing Generated Pictures

Due Thursday, February 7, at 3:30 PM

Create an app which draws a picture like the one shown in lab. The app should have three buttons:
  1. Fast: Sets the clock interval to 10 ms
  2. Slow: Sets the clock interval to 1000 ms
  3. Reset: Clears the canvas and restarts drawing

This lab will be primarily described during lab, and demonstrated. As a reference guide to building the app, I suggest building it in the following steps:
  1. Add three buttons. Set both the name and text to Fast, Slow, and Reset.
  2. Add a canvas, and set it to "fill parent" in both directions
  3. Add a clock, from the "sensors" section
  4. In Blocks, initialize a global variable named "count" to 0 (in variables)
  5. When the timer ticks, set global count to global count + 1 (increase count by 1)
  6. Set up an "easy" drawing scenario, to use while you get the rest of the app working. Call DrawLine on the canvas from within the clock's timer procedure. Set x1 to 10, y1 to global.count * 10, x2 to 100, and y2 to global.count * 10. This should cause a series of lines moving down your screen, like a ladder.
  7. Set up blocks for Slow, Fast, and Reset clicks. Reset should clear the canvas AND set global.count to 0
  8. Set up the radial figure. This all happens inside the clock's timer procedure. You'll need three local variables. angle should be global.count * 7, x should be the sine of angle, and y should be the sine of angle + 90. Then instead of drawing a line as described for the ladder, set x1 to (x*100) + 100, y1 to (y*100)+100, x2 to 100, and y2 to 100.

Turning in the Lab

Show me the finished version, and I will check off that you have finished.