[metapost] cloudit

David Van Horn dvanhorn at cs.brandeis.edu
Fri Apr 11 02:19:49 CEST 2008


I'm new to MetaPost and am trying to write a circleit-like macro that, 
instead of circling its contents, will draw a "cloud" around its 
contents.  As a first step, I've tried to just draw a cloud. 
(Understanding the definition of circleit is beyond my ability at this 

Here is what I've come up with---this draws a 5-pointed cloud:

   path p[], pcirc, pcloud; numeric n, a, t[]; pair v[];

   n = 5;
   a = 85;
   pcirc = fullcircle scaled 1cm;
   for i=0 upto n:
     t[i] = arctime i/n*arclength pcirc of pcirc;
     v[i] = direction t[i] of pcirc;

   pcloud =
   point t0 of pcirc{direction t0 of pcirc rotated -a}..
   {v1 rotated a}point t1 of pcirc{v1 rotated -a}..
   {v2 rotated a}point t2 of pcirc{v2 rotated -a}..
   {v3 rotated a}point t3 of pcirc{v3 rotated -a}..
   {v4 rotated a}point t4 of pcirc{v4 rotated -a}..
   {v5 rotated a}point t5 of pcirc..cycle;

   draw pcloud;

I'd like to generalize this to work for arbitrary values of n, but I 
don't see how to construct the pcloud path in general.

1) How can I generalize this?
2) How can I make a circleit like macro that draws a cloud around its 


More information about the metapost mailing list