Skip to content

Instantly share code, notes, and snippets.

@jstimpfle
Created June 3, 2017 16:27
Show Gist options
  • Save jstimpfle/3f297ece8e01f9364277113250537cbe to your computer and use it in GitHub Desktop.
Save jstimpfle/3f297ece8e01f9364277113250537cbe to your computer and use it in GitHub Desktop.
dabbling in postscript
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