summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/asymptote/examples/quilt.asy
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/asymptote/examples/quilt.asy')
-rw-r--r--Master/texmf-dist/doc/asymptote/examples/quilt.asy44
1 files changed, 44 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/asymptote/examples/quilt.asy b/Master/texmf-dist/doc/asymptote/examples/quilt.asy
new file mode 100644
index 00000000000..7a84017762c
--- /dev/null
+++ b/Master/texmf-dist/doc/asymptote/examples/quilt.asy
@@ -0,0 +1,44 @@
+import math;
+
+int n=8, skip=3;
+
+pair r(int k) { return unityroot(n,k); }
+
+pen col=blue, col2=purple;
+
+guide square=box((1,1),(-1,-1));
+
+guide step(int mult)
+{
+ guide g;
+ for(int k=0; k<n; ++k)
+ g=g--r(mult*k);
+ g=g--cycle;
+ return g;
+}
+
+guide oct=step(1), star=step(skip);
+
+guide wedge(pair z, pair v, real r, real a)
+{
+ pair w=expi(a/2.0);
+ v=unit(v)*r;
+ return shift(z)*((0,0)--v*w--v*conj(w)--cycle);
+}
+
+filldraw(square, col);
+filldraw(oct, yellow);
+
+// The interior angle of the points of the star.
+real intang=pi*(1-((real)2skip)/((real)n));
+
+for(int k=0; k<n; ++k) {
+ pair z=midpoint(r(k)--r(k+1));
+ guide g=wedge(z,-z,1,intang);
+ filldraw(g,col2);
+}
+
+fill(star,yellow);
+filldraw(star,evenodd+col);
+
+size(5inch,0);