Hi Mari, Am 30.04.2012 23:40, schrieb Mari Voipio: > On Mon, Apr 23, 2012 at 20:34, Mari Voipio <mari.voi...@iki.fi> wrote: >> a) I need to be able to stack four of these on top of each other and >> then four mirrored ones next to them > > OK, I really was being stupid - I had already managed to do a "shift" > inside a single 'block', somehow I just didn't see that I could do the > same to the blocks: > > > > \startMPpage > > > picture ll ; % left-hand loop > ll := > image ( > path p, q, r ; > > p := fullcircle scaled 4mm ; > q := p shifted (0mm,10mm) ; > r := center p .. (5mm,5mm) .. center q ; > > pair pr, qr ; > > pr := p intersectionpoint r ; > qr := q intersectionpoint r ; > > r := r cutbefore pr cutafter qr ; > r := r cutends 0.2mm ; > > draw r withpen pencircle scaled 0.2mm withcolor black ; % the > connecting curve > draw p withpen pencircle scaled 0.2mm withcolor black ; fill p > withcolor black ; % upper shank > draw q withpen pencircle scaled 0.2mm withcolor black ; fill q > withcolor black ; % lower shank > ); > > > draw ll ; > draw ll shifted (0mm,20mm) ; > draw ll shifted (0mm,40mm) ; > draw ll shifted (0mm,60mm) ; > > > \stopMPpage > > >> Keeping in mind that I >> will have to be able to draw a path/arrow on top, so I need to know >> where they are. > > My little brain got an overflow from all this abstract thinking, but > then it dawned on me that I could use the millimeter grid recipe in > the MetaFun manual (p. 214) to draw a grid behind my pattern drawing. > Now placing the arrows should be a walk in the park... > > > >> b) The circles p and q can be filled with the same colour or two >> different colours, and each of the blocks in a pattern can have >> different fill colour >> >> I assume the answer is "use variables", but how? > > Gaah, I still cannot figure it out! > A real example: one of my own patterns has white up and down on first > loop, black up white down on second, white up and down on third and > blue up and down on fourth. So I'd need > > draw ll ; % and fill both circles with white > draw ll shifted (0mm,20mm) ; % and fill lower circle with white, > shifted/upper circle with black > draw ll shifted (0mm,40mm) ; % fill both circles with white > draw ll shifted (0mm,60mm) ; % fill both circles with blue > > > What is the shortest way of doing this? I don't mind writing > definitions earlier in the file, but I'd rather keep this part as > short as possible to be able to see the pattern at one glance. The > main problem comes from the bicoloured loops as I can't just apply the > same fill on both. And on the whole I'd prefer to make sure I apply > the fill only locally per each half-loop and not all over the place... > donno what is the shortest way, but this looks at least handy...
\startMPinclusions patternsize:= 20mm; def lhl(expr ca,cb,sx,sy) = picture lefthandloop; lefthandloop := image ( path p, q, r ; p := fullcircle scaled 4mm ; q := p shifted (0mm,10mm) ; r := center p .. (5mm,5mm) .. center q ; r := r cutbefore (p intersectionpoint r) cutafter (q intersectionpoint r) ; draw r withpen pencircle scaled 0.2mm withcolor black ; % the connecting curve fill p withcolor ca; draw p withpen pencircle scaled 0.2mm withcolor black ; % upper shank fill q withcolor cb; draw q withpen pencircle scaled 0.2mm withcolor black ; % lower shank ); draw lefthandloop shifted (sx*patternsize,sy*patternsize); enddef; \stopMPinclusions \startMPpage lhl(white,white,0,0); lhl(white,black,0,1); lhl(white,white,0,2); lhl(blue ,blue ,0,3); \stopMPpage Best wishes, Peter ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________