I need to create a logo (well, a part of it) as an outline. The relevant part in MetaPost looks:

  path ellipse;
  ellipse = fullcircle xscaled 5in yscaled 1in;
  for k = 0 step 45 until 135:
    fill ellipse rotated k;

  for k = 0 step 45 until 135:
    unfill ellipse scaled 0.8 rotated k;


With this I got

white filled flower

because unfill is just a fill with white.

I would like to get an eps, pdf, or svg with empty area inside. Like this:

empty filled flower

Of course, if would be nice if the curves be optimal because otherwise the logo would make some unpleasant surprises while used in texts. The optimal solution is just two path: one consisting of 16 Bézier curves going anticlockwise followed by another internal path consisting of 16 smaller Bézier curves.

Right now I just exported black and white logo to 6000dpi png and used the program autotrace to get the curves. Is there a more elegant way to do it?

  • I think that the only way to do this in Metapost will be to define a path and a pen that gives you the desired outline. Metapost cannot convert the intersection of two filled regions into a path.
    – Aditya
    Sep 8, 2017 at 13:44

1 Answer 1


I'm no MetaPost wizard, but after a little experimentation I got this result.

  path ellipse, segment, outline, outside, inside;
  pair start, stop;

  ellipse = fullcircle xscaled 5in yscaled 1in;
  stop := ellipse intersectionpoint (ellipse rotated 45);
  start := (ellipse rotated -45) intersectionpoint ellipse;
  segment := (ellipse cutbefore start) -- (ellipse cutafter stop);
  outline := segment for k = 45 step 45 until 315: -- segment rotated k endfor -- cycle;

  outside := outline;
  inside := outline scaled 0.8;

  fill outside -- (reverse inside) -- cycle;

I modified your code to get the flowery shape into a path variable outline. Then I used a trick to only fill in the area inbetween the two curves. I don't know a proper reference for it; the Metafun manual (section 1.5) does talk about it, saying

This feature depends on the POSTSCRIPT way of filling closed paths, which comes down to filling either the left or the right hand side of a curve.

Notice the reverse, which serves a critical role: it reverses the orientation of the inner path. If you draw instead of fill the shape, you'll see some more of what's going on.

As @Aditya alludes to, MetaPost can't really unfill areas. But in special cases you can use this approach to get around that limitation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.