asymptote: tube

 
 8.34 'tube'
 ===========
 
 This package extends the 'tube' surfaces constructed in
 'three_arrows.asy' to arbitrary cross sections, colors, and spine
 transformations.  The routine
 surface tube(path3 g, coloredpath section,
              transform T(real)=new transform(real t) {return identity();},
              real corner=1, real relstep=0);
 draws a tube along 'g' with cross section 'section', after applying the
 transformation 'T(t)' at 'relpoint(g,t)'.  The parameter 'corner'
 controls the number of elementary tubes at the angular points of 'g'.  A
 nonzero value of 'relstep' specifies a fixed relative time step (in the
 sense of 'relpoint(g,t)') to use in constructing elementary tubes along
 'g'.  The type 'coloredpath' is a generalization of 'path' to which a
 'path' can be cast:
 struct coloredpath
 {
   path p;
   pen[] pens(real);
   int colortype=coloredSegments;
 }
 Here 'p' defines the cross section and the method 'pens(real t)' returns
 an array of pens (interpreted as a cyclic array) used for shading the
 tube patches at 'relpoint(g,t)'.  If 'colortype=coloredSegments', the
 tube patches are filled as if each segment of the section was colored
 with the pen returned by 'pens(t)', whereas if 'colortype=coloredNodes',
 the tube components are vertex shaded as if the nodes of the section
 were colored.
 
    A 'coloredpath' can be constructed with one of the routines:
 coloredpath coloredpath(path p, pen[] pens(real),
                         int colortype=coloredSegments);
 coloredpath coloredpath(path p, pen[] pens=new pen[] {currentpen},
                         int colortype=coloredSegments);
 coloredpath coloredpath(path p, pen pen(real));
 In the second case, the pens are independent of the relative time.  In
 the third case, the array of pens contains only one pen, which depends
 of the relative time.
 
    The casting of 'path' to 'coloredpath' allows the use of a 'path'
 instead of a 'coloredpath'; in this case the shading behaviour is the
 default shading behavior for a surface.
 
    An example of 'tube' is provided in the file 'trefoilknot.asy'.
 Further examples can be found at
 <http://www.piprime.fr/files/asymptote/tube/>.