Metapost Sandbox
Debug
save
Save
play_arrow
Run
download
Export
share
Share
Link to share
Embed
person
Login using Github
My work
New...
Log out
Documentation
About
beginfig(0); numeric s; s = 10; %First a basic path (named atom) is defined, path atom; atom = origin -- (2s,0) rotated -30 -- (2s,0) rotated -30 + (0,s) -- ( s,0) rotated 30 -- ( s,0) rotated 30 + (0,s) -- (0,2s) -- cycle; % then in the first loop three picture variables, p1, p2, and p3, are defined % each one rotated 120° from the previous and % filled with a slightly darker shade of grey. picture p[]; for i=0 upto 2: p[i] = image( fill atom rotated -120i withcolor (7/8 - 1/8i) ; draw atom rotated -120i; ); endfor pair u, v; u = point 3 of atom - point 1 of atom rotated -120; v = u rotated 60; n = 13; % The double loop then draws the three %versions of the shape on an up-and-down grid. for i=-n upto n: for j=-n upto n: forsuffixes $=0,1,2: draw p$ shifted (i*u + j*v); endfor endfor endfor % Finally the picture is clipped to a neat rectangle. clip currentpicture to unitsquare shifted -(1/2,1/2) scaled 10in yscaled 0.618; endfig; % Credits https://tug.ctan.org/info/drawing-with-metapost/Drawing-with-Metapost.pdf