For Programmers: Free Programming Magazines  


Home > Archive > PostScript > November 2005 > Decagonal tiling - nice pattern but slow drawing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Decagonal tiling - nice pattern but slow drawing
se_anderson

2005-11-29, 12:28 am

I have been using postscript to create tiling patterns. In this program a decagon is drawn, then each vertex of that decagon becomes the centre of a smaller decagon (scaled by the golden ratio). This is done recursively and eventually an interesting tiling emerges, similar to penrose tiling, but more intricate. The drawing process is very slow, partly because much of the action is happening out of the bounding box but also because the same decagons are redrawn many times. I am looking for some constructive criticism on my coding, especially ways I can speed up the creation of the image.
This is the source;

%!PS-Adobe-1.0
%%Title: Decagon Tiling - based on polygon and fractal tree with golden ratios and 3pi/5 (216 degree) angles
%%Creator: Stuart Anderson
%%CreationDate: Jan 29 2005
%%BoundingBox: 0 20 640 800
%%Pages: 1
%%EndProlog
%%Page:1 1
/depth 0 def

/maxdepth 7 def
/down {/depth depth 1 add def} def
/up {/depth depth 1 sub def} def
/poly {
/length exch def
/rep exch def
/rot 360 rep div def
/count 0 def
rep {
/count count 1 add def
count 1 eq
{ length 0 moveto
rot rotate} if
length 0 lineto
rot rotate
}repeat
} def


/polygold
{ gsave 0.618033989 0.618033989 scale % reduce scale by golden ratio
.1 setlinewidth % set line width
down 10 50 poly % print line
currentpoint translate
0 0 moveto
depth maxdepth le % depth<max. depth?
{ 216 rotate
polygold
216 rotate
polygold
216 rotate
polygold
216 rotate
polygold
216 rotate
polygold
stroke
} if
up grestore } def

% ------------ Begin program -------
-180 500 translate
16 16 scale
polygold
stroke
showpage
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com