Skip to content

Instantly share code, notes, and snippets.

@hmenke
Last active November 17, 2019 22:37
Show Gist options
  • Save hmenke/9dcdc9808507e76e9e6640263734fb8a to your computer and use it in GitHub Desktop.
Save hmenke/9dcdc9808507e76e9e6640263734fb8a to your computer and use it in GitHub Desktop.
MetaFun flags
\startMPpage
vardef star(expr r) =
save x, y ;
z1 = (r*cosd(90+0*360/5),r*sind(90+0*360/5)) ;
z2 = (r*cosd(90+1*360/5),r*sind(90+1*360/5)) ;
z3 = (r*cosd(90+2*360/5),r*sind(90+2*360/5)) ;
z4 = (r*cosd(90+3*360/5),r*sind(90+3*360/5)) ;
z5 = (r*cosd(90+4*360/5),r*sind(90+4*360/5)) ;
z1 -- z3 -- z5 -- z2 -- z4 -- cycle
enddef ;
numeric u ; u := .2cm ;
color Red, Gold ;
Red := (222/255, 41/255, 16/255) ;
Gold := (255/255,222/255, 0/255) ;
fill unitsquare xyscaled (2*15u,2*10u) yshifted (-2*10u) withcolor Red ;
fill star(3u) shifted (5u,-5u) withcolor Gold ;
fill star(1u) rotated (90+atan(3/5)) shifted (10u,-2u) withcolor Gold ;
fill star(1u) rotated (90+atan(1/7)) shifted (12u,-4u) withcolor Gold ;
fill star(1u) rotated (90-atan(2/7)) shifted (12u,-7u) withcolor Gold ;
fill star(1u) rotated (90-atan(4/5)) shifted (10u,-9u) withcolor Gold ;
\stopMPpage
\startMPpage
numeric u ; u := 1cm ;
color Red ;
Red := (188/255,0,45/255) ;
fill fullsquare xyscaled (3u,2u) withcolor white ;
fill fullcircle scaled (3/5*2u) withcolor Red ;
\stopMPpage
\startMPpage
numeric u ; u := 1pt ;
numeric w, h, d ;
w := (25 + 2 + 6 + 2 + 25)*u ;
h := (10 + 2+ 6 + 2 + 10)*u ;
d := sqrt(w*w + h*h) ;
color Blue, Red ;
Blue := (1/255, 33/255, 105/255) ;
Red := (200/255, 16/255, 46/255) ;
path p ;
p := fullsquare xyscaled (w, h) ;
fill p withcolor Blue ;
fill fullsquare xyscaled (d, 6u) rotated (+atan(h/w)) withcolor white ;
fill fullsquare xyscaled (d, 6u) rotated (-atan(h/w)) withcolor white ;
fill unitsquare xyscaled (d/2, 2u) rotated (atan(h/w)) withcolor Red ;
fill unitsquare xyscaled (d/2, 2u) rotated (180-atan(h/w)) withcolor Red ;
fill unitsquare xyscaled (d/2, 2u) rotated (-atan(h/w)) withcolor Red ;
fill unitsquare xyscaled (d/2, 2u) rotated (-180+atan(h/w)) withcolor Red ;
fill fullsquare xyscaled (w, 10u) withcolor white ;
fill fullsquare xyscaled (10u, h) withcolor white ;
fill fullsquare xyscaled (w, 6u) withcolor Red ;
fill fullsquare xyscaled (6u, h) withcolor Red ;
clip currentpicture to p ;
\stopMPpage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment