go to previous page   go to home page   go to next page highlighting

Answer:

See below.


Nested Rectangles Scene Graph

Scene graph with two rectangles

The root of the scene graph is a Group. The nine rectangles are children of the root. When the scene is rendered (used to make a picture), the graphics system traverses the graph, looking in each object for its color, size, and location.

The scene graph is rendered in the order that Shapes were added to it. So in this scene graph the first rectangle (at scale=0.9) is drawn first. If you set the fill colors of the rectangles to something other than TRANSPARENT this will affect the picture.

If you draw solid rectangles, draw the largest rectangle first (as here) so that the smaller rectangles are placed on top of it and are visible. This is one of the exercises for this chapter.


QUESTION 8:

Here are (again) the two parts to recursion:

  1. If the problem is easy, solve it immediately.
  2. If the problem can't be solved immediately, divide it into easier problems, then:
    • Solve the easier problems using this method.

For the nested rectangles, there are two parts, also.

What is the easy problem that can be solved in one step?
What is the big problem that must be divided into smaller problems?

go to previous page   go to home page   go to next page