| 1 |
% muslimpattern.mp |
| 2 |
% L. Nobre G. |
| 3 |
% 2012 |
| 4 |
|
| 5 |
prologues := 1; |
| 6 |
background := 0.9white; |
| 7 |
|
| 8 |
numeric u, pa, pb, hexf; |
| 9 |
u = 35mm; |
| 10 |
pa = 0.12u; |
| 11 |
pb = 0.05u; |
| 12 |
hexf = sqrt(3)/2; |
| 13 |
|
| 14 |
vardef markpath( expr Pat ) = |
| 15 |
draw Pat withpen pencircle scaled pa; |
| 16 |
undraw Pat withpen pencircle scaled pb; |
| 17 |
enddef; |
| 18 |
|
| 19 |
vardef hc( expr Xindex, Yindex ) = |
| 20 |
2*u*hexf*(Xindex*right+Yindex*dir(60)) |
| 21 |
enddef; |
| 22 |
|
| 23 |
beginfig(1); |
| 24 |
numeric i, ang; |
| 25 |
pair c, b, a, d; |
| 26 |
a = (hexf,0); |
| 27 |
b = (0.33hexf,-0.4); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHANGE only this. |
| 28 |
c = (0,1.5); |
| 29 |
d = 1.1[b,a]; |
| 30 |
path seg[], aux, hex, auxa, auxb; |
| 31 |
for i=0 upto 5: |
| 32 |
seg[i] = (d--b--c) rotated (i*60) scaled u; |
| 33 |
endfor; |
| 34 |
seg6 = seg0; |
| 35 |
ang = angle(c-b); |
| 36 |
aux = ((a-dir(ang))--(a+dir(ang))) scaled u; |
| 37 |
z1 = seg0 intersectionpoint seg5; |
| 38 |
z2 = seg0 intersectiontimes seg5; |
| 39 |
z3 = unitvector( direction xpart z2 of seg0 ); |
| 40 |
for i=1 upto 6: |
| 41 |
markpath( aux rotated (i*60) ); |
| 42 |
markpath( seg[i-1] ); |
| 43 |
endfor; |
| 44 |
auxa = ((a-pb*dir(ang)/u)--(a+pb*dir(ang)/u)) scaled u; |
| 45 |
auxb = ((a-pa*dir(ang)/u)--(a+pa*dir(ang)/u)) scaled u; |
| 46 |
for i=1 upto 6: |
| 47 |
draw auxa rotated ((i-1)*60) withpen pencircle scaled pa; |
| 48 |
undraw auxb rotated ((i-1)*60) withpen pencircle scaled pb; |
| 49 |
endfor; |
| 50 |
auxa := ((z1-pb*z3)--(z1+pb*z3)); |
| 51 |
auxb := ((z1-pa*z3)--(z1+pa*z3)); |
| 52 |
draw auxa withpen pencircle scaled pa; |
| 53 |
undraw auxb withpen pencircle scaled pb; |
| 54 |
hex = for i=30 step 60 until 360: u*dir(i)-- endfor cycle; |
| 55 |
clip currentpicture to hex; |
| 56 |
picture tile; |
| 57 |
tile = currentpicture; |
| 58 |
endfig; |
| 59 |
|
| 60 |
beginfig(2); |
| 61 |
numeric i, j; |
| 62 |
path rect; |
| 63 |
rect = hc(0,-1)--hc(1,-1)--hc(0,1)--hc(-1,1)--cycle; |
| 64 |
fill rect withcolor (1,0.986,0.993); |
| 65 |
for i=-1 upto 1: |
| 66 |
for j=-1 upto 1: |
| 67 |
draw tile shifted hc(i,j); |
| 68 |
endfor; |
| 69 |
endfor; |
| 70 |
clip currentpicture to rect; |
| 71 |
endfig; |
| 72 |
|
| 73 |
end. |