TopSimplifying Boolean ExpressionsNested Loops

Nested Loops

Suppose I want to draw a scarf where each row of the scarf is a sequence of overlapping ovals.

I can write each row (at y-coordinate given by y as follows:

      var numCols: Number := 0
      var x := point.x  // x position of the next "stitch"

      while {numCols < scarfWidth} do {
        def stitch: Graphic2D = 
                framedOval.at(x @ y) size (diameter,diameter) on (canvas)
        stitch.color := scarfColor
        x := x + xSpace
        numCols := numCols + 1
      }

What do we have to add to draw a lot of rows? Nested loops! See scarf.


TopSimplifying Boolean ExpressionsNested Loops