summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/koch.xp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/epix/samples/koch.xp
Initial commit
Diffstat (limited to 'graphics/epix/samples/koch.xp')
-rw-r--r--graphics/epix/samples/koch.xp38
1 files changed, 38 insertions, 0 deletions
diff --git a/graphics/epix/samples/koch.xp b/graphics/epix/samples/koch.xp
new file mode 100644
index 0000000000..8a9683715c
--- /dev/null
+++ b/graphics/epix/samples/koch.xp
@@ -0,0 +1,38 @@
+/* -*-ePiX-*- */
+/* koch.c -- May 29, 2002 */
+#include "epix.h"
+using namespace ePiX;
+
+const int koch_seed[] = {6, 4, 0, 1, -1, 0};
+
+int main()
+{
+ picture(P(0,0), P(4, 1), "6 x 1.5in");
+
+ begin();
+ degrees();
+
+ for (int i=1; i <= 4; ++i)
+ {
+ // draw von Koch curve at "depth" i
+ screen tmp(P(-1,-1), P(1,1));
+ activate(tmp);
+
+ if (i==1)
+ {
+ bold(Red());
+ fractal(cis(150), cis(30), i, koch_seed);
+ plain(Black());
+ }
+ else
+ fractal(cis(150), cis( 30), i, koch_seed);
+
+ fractal(cis( 30), cis(-90), i, koch_seed);
+ fractal(cis(-90), cis(150), i, koch_seed);
+
+ inset(tmp, P(i-1,0), P(i,1));
+ deactivate(tmp);
+ }
+ end();
+}
+