Friday, February 24, 2012

Project 4

Two new functions that were introduced in this chapter were the save() and restore(). What these functions do is that they are used to save and retrieve the canvas state. So every time the save method is called the current drawing is pushed on a stack, and every time restore method is called, the last saved state is returned from the stack and all saved settings are restored. So in this example I used both of them but what I first did was draw a rectangle and save it. Then I made changes to the settings and drew a new rectangle with new settings. So I saved that current and did new changes to it. After that I restored the previous state and drew a rectangle with restored settings. The last step was restore the original state and draw a rectangle with restored settings. This took quite a while but I think the save() and restore() function are really easy and simple to use. To see the outcome please click here.

1 comment:

  1. The part I don't understand is what specifically is "the canvas state" that is being saved? How would your image look different if the method calls to save() and restore() were removed? That would be a good exercise for the beginning of next week. Show what the draw() function would generate without the save() and restore() method calls, and use this to explain what specifically they are doing.

    ReplyDelete