Created
June 3, 2017 16:27
-
-
Save jstimpfle/3f297ece8e01f9364277113250537cbe to your computer and use it in GitHub Desktop.
dabbling 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
1 setlinewidth | |
% move somewhere near the center of an A4/letter page | |
100 500 moveto | |
% string -> (Write the string) | |
/logstring | |
{ | |
(%stdout) (w) file | |
exch writestring | |
} def | |
% line-width -> (line-width, (draw the thing)) | |
/line | |
{ | |
dup 0 rlineto | |
} | |
def | |
% (recdepth, width) -> (recdepth, width, draw the string) | |
/koch-rec | |
{ | |
2 copy exch | |
dup 0 eq | |
{ | |
pop | |
0 rlineto | |
} | |
{ | |
-1 add exch | |
3 div | |
koch-rec | |
-90 rotate | |
koch-rec | |
90 rotate | |
koch-rec | |
90 rotate | |
koch-rec | |
-90 rotate | |
koch-rec | |
pop | |
pop | |
} | |
ifelse | |
} | |
def | |
/koch | |
{ | |
400 koch-rec | |
pop | |
pop | |
stroke | |
} def | |
5 koch | |
showpage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment