Candy Cane Stock Chart

artwork
#include "colors.inc"
#include "stones.inc" 
#include "textures.inc"


camera{
  location <17,10,-25>
  look_at <17,10,0>
} 


light_source{
  <60,0,-100>
  color rgb <1,1,1>
}
#declare i = 0;
#while(i < 25)  
cylinder{
 <-100,i,1> <100,i,1> .2
 pigment{color rgb <1,1,1>}

}
#declare i = i + 1;
#end
#declare i = 0;
#while(i < 20)  
cylinder{
 <-100,-i,1> <100,-i,1> .2
 pigment{color rgb <1,1,1>}

}
#declare i = i + 1;
#end






#macro stem(o)
        cylinder{
         o o+<0,2,0>
         .2
         
        }
#end 

#macro top(o)
        torus{
          .4 .2
          rotate <90,0,0>
          
           
           clipped_by{box{<-1,0,1> <1,.7,-1>}}
           translate <.4,0,0>
          translate o
        } 
        
#end 

#macro cane1(o)
   union{
   stem(<0,0,0>)
   top(<0,2,0>)
   texture{Candy_Cane scale .5 finish{phong 1}}
   translate o
   }
#end

#macro cane2(o)
   union{
   stem(<0,0,0>)
   top(<0,2,0>)
   texture{Candy_Cane scale .5 finish{phong 1}}
   rotate <0,180,0> 
   rotate <180,0,0>
   translate <.8,0,0>
   translate <0,2,0>
   translate o
   }
#end

#macro cane3(o)
   union{
   stem(<0,0,0>)
   top(<0,2,0>)
   texture{Candy_Cane scale .5 finish{phong 1}}
   rotate <0,180,0>
   translate <0,-2,0>
   translate <.8,0,0> 
   translate o
   }
#end

#macro cane4(o)
   union{
   stem(<0,0,0>)
   top(<0,2,0>)
   texture{Candy_Cane scale .5 finish{phong 1}}
   rotate <180,0,0>
   translate o
   }
#end



plane{
 z 1
 pigment{color rgb <1,1,1>}
}




/*#declare o = <0,0,0>;
cane1(o)
sphere{<.8,2,0> .2 pigment{color rgb <1,1,1>}finish{phong 1}}
cane2(<.8,2,0>)
sphere{<1.6,4,0> .2 pigment{color rgb <1,1,1>}finish{phong 1}}
cane3(<1.6,4,0>)
 sphere{<2.4,2,0> .2 pigment{color rgb <1,1,1>}finish{phong 1}}
cane4(<2.4,2,0>)*/

#declare r = seed(5);
#declare o = <0,0,0>;
#macro rw(o)
#local i = 0;
#while(i < 100)
 #local rn = rand(r);
 #if(rn < .5)
 cane1(o)
 #local o = o + <.8,2,0>;
 #else
   cane3(o)
 #local o = o + <.8,-2,0>;

 #end
 
 #local rn = rand(r);
 #if(rn < .5)
  cane2(o)
 #local o = o + <.8,2,0>;
 #else
 cane4(o)
 #local o = o + <.8,-2,0>;
 #end
 #local i = i + 1;
 #end
#end 

rw(<0,0,0>)