Created
January 6, 2016 18:36
-
-
Save aaronpuchert/1186a63b4f7866464e8e to your computer and use it in GitHub Desktop.
Sierpinski triangle in PostScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!PS-Adobe-3.0 | |
%%Creator: Aaron Puchert | |
%%Title: The Spierpinski triangle | |
%%Pages: 1 | |
%%PageOrder: Ascend | |
%%BeginProlog | |
% PAGE SETTINGS | |
/pageset { | |
28.3464566 28.3464566 scale % set cm = 1 | |
0.5 0.5 translate | |
0 setlinewidth | |
} def | |
%---------- | |
% MACRO | |
%---------- | |
% sierpinski(n) draws a sierpinski triangle of order n | |
/sierpinski { | |
dup 0 gt | |
{ [0.5 0 0 0.5 0 0] concat dup 1 sub sierpinski | |
[1 0 0 1 1 0] concat dup 1 sub sierpinski | |
[1 0 0 1 -1 1] concat dup 1 sub sierpinski | |
[2 0 0 2 0 -1] concat} | |
{ newpath | |
0 0 moveto | |
1 0 lineto | |
0 1 lineto | |
closepath | |
fill} | |
ifelse pop} def | |
%%EndProlog | |
%%BeginSetup | |
<< /PageSize [596 843] >> setpagedevice % A4 | |
%%EndSetup | |
%---------------------------- | |
% ACTUAL PAGE DEFINITION | |
%---------------------------- | |
%%Page: 1 1 | |
pageset | |
[20 0 10 300 sqrt 0 0] concat | |
9 sierpinski | |
showpage | |
%%EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment