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
input plain_ex; input mpcolornames; beginfig(0); p:=0; thick:= 100; thin:= thick*0.5; vardef thick_nib = fix_nib(thick, 0, 0) enddef; vardef thin_nib = fix_nib(0, thin, 0) enddef; path paths[], strokes[]; m:=500; z0 = (x1+0.4m, 0); z1 = (0, (y0+y2)/2); z2 = ((x1+x3)/2, m); z3 = (x1+0.75m, (y2+y4)/2); z4 = (x3, 0); paths[p] = z0{left}..{up}z1 ..z2{right}..z3---z4; pen_stroke( cut(thin_nib, 90)(0) nib(thick_nib)(1,3,4) nib(thin_nib)(2) )(paths[p])(strokes[p]); % diamond vardef diamond(expr p, t) = z0=point t+0.2 of p; z1=point t of p+(m/6,0); z2=point t-0.2 of p; z3=point length(p)-1-t+0.2 of p; z4=point length(p)-1-t of p-(m/6,0); z5=point length(p)-1-t-0.2 of p; z0..{right}z1{left}..z2--z3..{left}z4{right}..z5--cycle enddef; clearxy; p:=p+1; z0=point 3 of paths[0]; z1=((x0+x2)/2,m); z2=(x0+0.6m,(y1+y3)/2); z3=((x2+x4)/2, 0); z4=(x2+0.6m, y2); z5=(x2+0.2m, m); paths[p] = z0{up}..z1{right}..z2{dir 260}..z3{right}..z4{up}..{left}z5; pen_stroke( nib(thick_nib)(0,2,4) nib(thin_nib)(1,3) cut(thin_nib, 90)(6) )(paths[p])(strokes[p]); clearxy; p:=p+1; strokes[p] = diamond(strokes[0], 1); clearxy; p:=p+1; strokes[p] = diamond(strokes[0], 6); clearxy; p:=p+1; strokes[p] = diamond(strokes[1], 4); clearxy; p:=p+1; strokes[p] = diamond(strokes[1], 9); % terminal flower rightwords clearxy; p:=p+1; z0=point -0.5 of strokes[0]+(m/10, 0); z1=point 0 of strokes[0]+(0, m/10); z2=point 0.2 of strokes[0]; z3=point -1.1 of strokes[0]; z4=point -1 of strokes[0]-(0,m/10); strokes[p]= z0{left}..{up}z1{down}..z2--z3..{down}z4{up}..{right}cycle; % terminal flower leftwords clearxy; p:=p+1; z0=point 4.9 of strokes[1]; z1=point 5 of strokes[1]+(0,m/10); z2=point 5.5 of strokes[1]-(m/10,0); z3=point 6 of strokes[1]-(0,m/10); z4=point 6.1 of strokes[1]; strokes[p]= z0{left}..{up}z1{down}..{left}z2{right}..{down}z3{up}..{right}z4--cycle; % terminal flower downwards clearxy; p:=p+1; z0=point 3.8 of strokes[0]; z1=point 4 of strokes[0] - (m/10, 0); z2=point 4.5 of strokes[0] - (0,m/6); z3=point 5 of strokes[0] + (m/10, 0); z4=point 5.2 of strokes[0]; strokes[p]=z0{down}..{left}z1{right}..{down}z2{up}..{right}z3{left}..{up}z4--cycle; for i=0 upto 10: if known strokes[i]: fill strokes[i] withcolor Teal; %draw strokes[i] withcolor White; fi; if known paths[i]: draw paths[i] withcolor Gold; fi; endfor; endfig; end