1. // Grow Hairs
  2. vector dir = { 0, 1, 0 };
  3. // dir = @N;    // grow in normal direction
  4. float len = 1.0;
  5. int   steps = 10;
  6. float jitter = 0.1;
  7. float seed = 0.12345;
  8.  
  9. vector  pos = @P;
  10. int             pr = addprim(geoself(), "polyline");
  11.  
  12. // Start the curve with our point
  13. addvertex(geoself(), pr, @ptnum);
  14. for (int i = 0; i < steps; i++)
  15. {
  16.     pos += dir * len / steps;
  17.     pos += (vector(rand( @ptnum + seed )) - 0.5) * jitter;
  18.  
  19.     // Clone our point to copy attributes
  20.     int pt = addpoint(geoself(), @ptnum);
  21.     // But write a new position
  22.     setpointattrib(geoself(), "P", pt, pos);
  23.  
  24.     // Connect the new point to our curve.
  25.     addvertex(geoself(), pr, pt);
  26.     seed += $PI;
  27. }