Next: Affine arithmetic, Previous: Polygon sweeps, Up: Swept objects

#### 2.7.5 Polyline sweeps with closure

A polyline sweep with a closure tag creates another kind of closed surface. First, the polyline segments are connected by faces, just as without the closure tag. Then, each set of end points is joined to make a polygon, one for each end. A code for several views of a cylindrical prism follows.

      def n_cyl_segs 20  def n_views 5  def I [1,0,0]
      def endopts [fillcolor=lightgray]
      repeat { n_views, rotate(180/n_views, [I]) then translate([I] * 2.1) }
        sweep[endopts]{ n_cyl_segs<>, rotate(360/n_cyl_segs, [0,1,0]) }
          line[fillcolor=white](1,-1)(1,1)

It produces this drawing.

The options of the swept line, if any, are applied to the faces produced by sweeping the line, but not the end polygons. Otherwise, the sweep options are applied throughout. The `def` in this example is an option definition. References to options must be enclosed in square brackets, e.g. `[foo]`. Happily, the syntax of `sketch` is such that options references can never be confused with vector references. While not apparent in this example, options references are useful when defining many objects with a similar appearance.